(t *testing.T)
| 1548 | } |
| 1549 | |
| 1550 | func TestQuitQuitQuitWithErrors(t *testing.T) { |
| 1551 | c := NewCommand(WithDialer(&errorDialer{})) |
| 1552 | c.SilenceUsage = true |
| 1553 | c.SilenceErrors = true |
| 1554 | c.SetArgs([]string{ |
| 1555 | "--quitquitquit", "--admin-port", "9193", |
| 1556 | "my-project:my-region:my-instance", |
| 1557 | }) |
| 1558 | ctx, cancel := context.WithCancel(context.Background()) |
| 1559 | defer cancel() |
| 1560 | |
| 1561 | errCh := make(chan error) |
| 1562 | go func() { |
| 1563 | err := c.ExecuteContext(ctx) |
| 1564 | errCh <- err |
| 1565 | }() |
| 1566 | resp, err := tryDial("POST", "http://localhost:9193/quitquitquit") |
| 1567 | if err != nil { |
| 1568 | t.Fatalf("failed to dial endpoint: %v", err) |
| 1569 | } |
| 1570 | if resp.StatusCode != http.StatusOK { |
| 1571 | t.Fatalf("expected a 200 status, got = %v", resp.StatusCode) |
| 1572 | } |
| 1573 | // The returned error is the error from closing the dialer. |
| 1574 | got := <-errCh |
| 1575 | if !strings.Contains(got.Error(), "close failed") { |
| 1576 | t.Fatalf("want = %v, got = %v", errCloseFailed, got) |
| 1577 | } |
| 1578 | } |
nothing calls this directly
no test coverage detected