TestWaitForTask_APIError verifies that WaitForTask surfaces errors from the GetTask API call immediately without retrying.
(t *testing.T)
| 89 | // TestWaitForTask_APIError verifies that WaitForTask surfaces errors from the |
| 90 | // GetTask API call immediately without retrying. |
| 91 | func TestWaitForTask_APIError(t *testing.T) { |
| 92 | r := &httpmock.Registry{} |
| 93 | taskPath := "1/compositions/my-comp/task/42" |
| 94 | |
| 95 | r.Register( |
| 96 | httpmock.REST("GET", taskPath), |
| 97 | httpmock.ErrorResponse(), |
| 98 | ) |
| 99 | |
| 100 | f, _ := test.NewFactory(false, r, nil, "") |
| 101 | client, err := f.CompositionClient() |
| 102 | require.NoError(t, err) |
| 103 | |
| 104 | io, _, _, _ := iostreams.Test() |
| 105 | err = compinternal.WaitForTask(io, client, "my-comp", 42, testPollInterval, testTimeout) |
| 106 | require.Error(t, err) |
| 107 | // Only one request should have been made before returning. |
| 108 | assert.Len(t, r.Requests, 1, "expected WaitForTask to stop after first API error") |
| 109 | } |
nothing calls this directly
no test coverage detected