MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / TestCommandWithCustomDialer

Function TestCommandWithCustomDialer

cmd/root_test.go:1375–1394  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1373}
1374
1375func TestCommandWithCustomDialer(t *testing.T) {
1376 want := "my-project:my-region:my-instance"
1377 s := &spyDialer{}
1378 c := NewCommand(WithDialer(s))
1379 // Keep the test output quiet
1380 c.SilenceUsage = true
1381 c.SilenceErrors = true
1382 c.SetArgs([]string{want})
1383
1384 ctx, cancel := context.WithTimeout(context.Background(), time.Second)
1385 defer cancel()
1386
1387 if err := c.ExecuteContext(ctx); !errors.Is(err, errSigInt) {
1388 t.Fatalf("want errSigInt, got = %v", err)
1389 }
1390
1391 if got := s.instance(); got != want {
1392 t.Fatalf("want = %v, got = %v", want, got)
1393 }
1394}
1395
1396func tryDial(method, addr string) (*http.Response, error) {
1397 var (

Callers

nothing calls this directly

Calls 3

instanceMethod · 0.95
NewCommandFunction · 0.85
WithDialerFunction · 0.85

Tested by

no test coverage detected