add prune and remove unused packages
This commit is contained in:
135
vendor/google.golang.org/grpc/resolver/dns/dns_resolver_go19_test.go
generated
vendored
135
vendor/google.golang.org/grpc/resolver/dns/dns_resolver_go19_test.go
generated
vendored
@@ -1,135 +0,0 @@
|
||||
// +build go1.9
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright 2018 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package dns
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc/internal/leakcheck"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
func TestCustomAuthority(t *testing.T) {
|
||||
defer leakcheck.Check(t)
|
||||
|
||||
tests := []struct {
|
||||
authority string
|
||||
authorityWant string
|
||||
expectError bool
|
||||
}{
|
||||
{
|
||||
"4.3.2.1:" + defaultDNSSvrPort,
|
||||
"4.3.2.1:" + defaultDNSSvrPort,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"4.3.2.1:123",
|
||||
"4.3.2.1:123",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"4.3.2.1",
|
||||
"4.3.2.1:" + defaultDNSSvrPort,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"::1",
|
||||
"[::1]:" + defaultDNSSvrPort,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"[::1]",
|
||||
"[::1]:" + defaultDNSSvrPort,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"[::1]:123",
|
||||
"[::1]:123",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"dnsserver.com",
|
||||
"dnsserver.com:" + defaultDNSSvrPort,
|
||||
false,
|
||||
},
|
||||
{
|
||||
":123",
|
||||
"localhost:123",
|
||||
false,
|
||||
},
|
||||
{
|
||||
":",
|
||||
"",
|
||||
true,
|
||||
},
|
||||
{
|
||||
"[::1]:",
|
||||
"",
|
||||
true,
|
||||
},
|
||||
{
|
||||
"dnsserver.com:",
|
||||
"",
|
||||
true,
|
||||
},
|
||||
}
|
||||
oldCustomAuthorityDialler := customAuthorityDialler
|
||||
defer func() {
|
||||
customAuthorityDialler = oldCustomAuthorityDialler
|
||||
}()
|
||||
|
||||
for _, a := range tests {
|
||||
errChan := make(chan error, 1)
|
||||
customAuthorityDialler = func(authority string) func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
if authority != a.authorityWant {
|
||||
errChan <- fmt.Errorf("wrong custom authority passed to resolver. input: %s expected: %s actual: %s", a.authority, a.authorityWant, authority)
|
||||
} else {
|
||||
errChan <- nil
|
||||
}
|
||||
return func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
return nil, errors.New("no need to dial")
|
||||
}
|
||||
}
|
||||
|
||||
b := NewBuilder()
|
||||
cc := &testClientConn{target: "foo.bar.com"}
|
||||
r, err := b.Build(resolver.Target{Endpoint: "foo.bar.com", Authority: a.authority}, cc, resolver.BuildOption{})
|
||||
|
||||
if err == nil {
|
||||
r.Close()
|
||||
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
}
|
||||
|
||||
if a.expectError {
|
||||
t.Errorf("custom authority should have caused an error: %s", a.authority)
|
||||
}
|
||||
} else if !a.expectError {
|
||||
t.Errorf("unexpected error using custom authority %s: %s", a.authority, err)
|
||||
}
|
||||
}
|
||||
}
|
1020
vendor/google.golang.org/grpc/resolver/dns/dns_resolver_test.go
generated
vendored
1020
vendor/google.golang.org/grpc/resolver/dns/dns_resolver_test.go
generated
vendored
File diff suppressed because it is too large
Load Diff
27
vendor/google.golang.org/grpc/resolver/dns/go18_test.go
generated
vendored
27
vendor/google.golang.org/grpc/resolver/dns/go18_test.go
generated
vendored
@@ -1,27 +0,0 @@
|
||||
// +build go1.8
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright 2018 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package dns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var errForInvalidTarget = fmt.Errorf("invalid target address [2001:db8:a0b:12f0::1, error info: address [2001:db8:a0b:12f0::1:443: missing ']' in address")
|
27
vendor/google.golang.org/grpc/resolver/dns/pre_go18_test.go
generated
vendored
27
vendor/google.golang.org/grpc/resolver/dns/pre_go18_test.go
generated
vendored
@@ -1,27 +0,0 @@
|
||||
// +build go1.6, !go1.8
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright 2018 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package dns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var errForInvalidTarget = fmt.Errorf("invalid target address [2001:db8:a0b:12f0::1, error info: missing ']' in address [2001:db8:a0b:12f0::1:443")
|
91
vendor/google.golang.org/grpc/resolver/manual/manual.go
generated
vendored
91
vendor/google.golang.org/grpc/resolver/manual/manual.go
generated
vendored
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2017 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
// Package manual defines a resolver that can be used to manually send resolved
|
||||
// addresses to ClientConn.
|
||||
package manual
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
// NewBuilderWithScheme creates a new test resolver builder with the given scheme.
|
||||
func NewBuilderWithScheme(scheme string) *Resolver {
|
||||
return &Resolver{
|
||||
scheme: scheme,
|
||||
}
|
||||
}
|
||||
|
||||
// Resolver is also a resolver builder.
|
||||
// It's build() function always returns itself.
|
||||
type Resolver struct {
|
||||
scheme string
|
||||
|
||||
// Fields actually belong to the resolver.
|
||||
cc resolver.ClientConn
|
||||
bootstrapAddrs []resolver.Address
|
||||
}
|
||||
|
||||
// InitialAddrs adds resolved addresses to the resolver so that
|
||||
// NewAddress doesn't need to be explicitly called after Dial.
|
||||
func (r *Resolver) InitialAddrs(addrs []resolver.Address) {
|
||||
r.bootstrapAddrs = addrs
|
||||
}
|
||||
|
||||
// Build returns itself for Resolver, because it's both a builder and a resolver.
|
||||
func (r *Resolver) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOption) (resolver.Resolver, error) {
|
||||
r.cc = cc
|
||||
if r.bootstrapAddrs != nil {
|
||||
r.NewAddress(r.bootstrapAddrs)
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// Scheme returns the test scheme.
|
||||
func (r *Resolver) Scheme() string {
|
||||
return r.scheme
|
||||
}
|
||||
|
||||
// ResolveNow is a noop for Resolver.
|
||||
func (*Resolver) ResolveNow(o resolver.ResolveNowOption) {}
|
||||
|
||||
// Close is a noop for Resolver.
|
||||
func (*Resolver) Close() {}
|
||||
|
||||
// NewAddress calls cc.NewAddress.
|
||||
func (r *Resolver) NewAddress(addrs []resolver.Address) {
|
||||
r.cc.NewAddress(addrs)
|
||||
}
|
||||
|
||||
// NewServiceConfig calls cc.NewServiceConfig.
|
||||
func (r *Resolver) NewServiceConfig(sc string) {
|
||||
r.cc.NewServiceConfig(sc)
|
||||
}
|
||||
|
||||
// GenerateAndRegisterManualResolver generates a random scheme and a Resolver
|
||||
// with it. It also registers this Resolver.
|
||||
// It returns the Resolver and a cleanup function to unregister it.
|
||||
func GenerateAndRegisterManualResolver() (*Resolver, func()) {
|
||||
scheme := strconv.FormatInt(time.Now().UnixNano(), 36)
|
||||
r := NewBuilderWithScheme(scheme)
|
||||
resolver.Register(r)
|
||||
return r, func() { resolver.UnregisterForTesting(scheme) }
|
||||
}
|
Reference in New Issue
Block a user