MCPcopy
hub / github.com/grpc/grpc-go / pickAndCheckError

Function pickAndCheckError

balancer/weightedtarget/weightedtarget_test.go:75–85  ·  view source on GitHub ↗

pickAndCheckError returns a function which takes a picker, invokes the Pick() method multiple times and ensures that the error returned by the picker matches the provided error.

(want error)

Source from the content-addressed store, hash-verified

73// pickAndCheckError returns a function which takes a picker, invokes the Pick() method
74// multiple times and ensures that the error returned by the picker matches the provided error.
75func pickAndCheckError(want error) func(balancer.Picker) error {
76 const rpcCount = 5
77 return func(p balancer.Picker) error {
78 for i := 0; i < rpcCount; i++ {
79 if _, err := p.Pick(balancer.PickInfo{}); err == nil || !strings.Contains(err.Error(), want.Error()) {
80 return fmt.Errorf("picker.Pick() returned error: %v, want: %v", err, want)
81 }
82 }
83 return nil
84 }
85}
86
87func (t *testConfigBalancerBuilder) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer {
88 rr := t.Builder.Build(cc, opts)

Calls 3

PickMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected