TestWaitForTask_Timeout verifies that WaitForTask returns an error containing "timed out" when the task never reaches published within the timeout window.
(t *testing.T)
| 65 | // TestWaitForTask_Timeout verifies that WaitForTask returns an error containing |
| 66 | // "timed out" when the task never reaches published within the timeout window. |
| 67 | func TestWaitForTask_Timeout(t *testing.T) { |
| 68 | r := &httpmock.Registry{} |
| 69 | taskPath := "1/compositions/my-comp/task/42" |
| 70 | |
| 71 | // Register more stubs than we expect to consume so the registry doesn't |
| 72 | // run out before the timeout fires. |
| 73 | for range 100 { |
| 74 | r.Register(httpmock.REST("GET", taskPath), httpmock.StringResponse(`{"status":"notPublished"}`)) |
| 75 | } |
| 76 | |
| 77 | f, _ := test.NewFactory(false, r, nil, "") |
| 78 | client, err := f.CompositionClient() |
| 79 | require.NoError(t, err) |
| 80 | |
| 81 | io, _, _, _ := iostreams.Test() |
| 82 | err = compinternal.WaitForTask(io, client, "my-comp", 42, testPollInterval, testTimeout) |
| 83 | require.Error(t, err) |
| 84 | assert.Contains(t, err.Error(), "timed out") |
| 85 | assert.Contains(t, err.Error(), "42") |
| 86 | assert.Contains(t, err.Error(), "my-comp") |
| 87 | } |
| 88 | |
| 89 | // TestWaitForTask_APIError verifies that WaitForTask surfaces errors from the |
| 90 | // GetTask API call immediately without retrying. |
nothing calls this directly
no test coverage detected