(t *testing.T)
| 1373 | } |
| 1374 | |
| 1375 | func 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 | |
| 1396 | func tryDial(method, addr string) (*http.Response, error) { |
| 1397 | var ( |
nothing calls this directly
no test coverage detected