MCPcopy Create free account
hub / github.com/algolia/cli / TestWaitForTask_Timeout

Function TestWaitForTask_Timeout

pkg/cmd/compositions/internal/wait_test.go:67–87  ·  view source on GitHub ↗

TestWaitForTask_Timeout verifies that WaitForTask returns an error containing "timed out" when the task never reaches published within the timeout window.

(t *testing.T)

Source from the content-addressed store, hash-verified

65// TestWaitForTask_Timeout verifies that WaitForTask returns an error containing
66// "timed out" when the task never reaches published within the timeout window.
67func 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.

Callers

nothing calls this directly

Calls 6

RegisterMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
NewFactoryFunction · 0.92
TestFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected