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

Function setupClient

test/healthcheck_test.go:170–192  ·  view source on GitHub ↗
(t *testing.T, c *clientConfig)

Source from the content-addressed store, hash-verified

168}
169
170func setupClient(t *testing.T, c *clientConfig) (*grpc.ClientConn, *manual.Resolver) {
171 t.Helper()
172
173 r := manual.NewBuilderWithScheme("whatever")
174 opts := []grpc.DialOption{
175 grpc.WithTransportCredentials(insecure.NewCredentials()),
176 grpc.WithResolvers(r),
177 }
178 if c != nil {
179 if c.balancerName != "" {
180 opts = append(opts, grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, c.balancerName)))
181 }
182 opts = append(opts, c.extraDialOption...)
183 }
184
185 cc, err := grpc.NewClient(r.Scheme()+":///test.server", opts...)
186 if err != nil {
187 t.Fatalf("grpc.NewClient() failed: %v", err)
188 }
189 cc.Connect()
190 t.Cleanup(func() { cc.Close() })
191 return cc, r
192}
193
194func (s) TestHealthCheckWatchStateChange(t *testing.T) {
195 _, lis, ts := setupServer(t, nil)

Calls 10

NewBuilderWithSchemeFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewCredentialsFunction · 0.92
WithResolversFunction · 0.92
WithDefaultServiceConfigFunction · 0.92
NewClientFunction · 0.92
SchemeMethod · 0.65
FatalfMethod · 0.65
ConnectMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected