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

Function TestWaitForTask_APIError

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

TestWaitForTask_APIError verifies that WaitForTask surfaces errors from the GetTask API call immediately without retrying.

(t *testing.T)

Source from the content-addressed store, hash-verified

89// TestWaitForTask_APIError verifies that WaitForTask surfaces errors from the
90// GetTask API call immediately without retrying.
91func 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}

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected