MCPcopy Create free account
hub / github.com/cli/cli / TestGetBundle_SuccessfulRetry

Function TestGetBundle_SuccessfulRetry

pkg/cmd/attestation/api/client_test.go:273–288  ·  view source on GitHub ↗

getBundle retries successfully when the initial HTTP request returns a 5XX status code

(t *testing.T)

Source from the content-addressed store, hash-verified

271// getBundle retries successfully when the initial HTTP request returns
272// a 5XX status code
273func TestGetBundle_SuccessfulRetry(t *testing.T) {
274 mockHTTPClient := &failAfterNCallsHttpClient{
275 FailOnCallN: 1,
276 FailOnAllSubsequentCalls: false,
277 }
278
279 c := &LiveClient{
280 externalHttpClient: mockHTTPClient,
281 logger: io.NewTestHandler(),
282 }
283
284 b, err := c.getBundle(safeurl.NewImmutableSafeURL("mybundleurl"))
285 require.NoError(t, err)
286 require.Equal(t, "application/vnd.dev.sigstore.bundle.v0.3+json", b.GetMediaType())
287 mockHTTPClient.AssertNumberOfCalls(t, "OnGetFailAfterNCalls", 2)
288}
289
290// getBundle does not retry when the function fails with a permanent backoff error condition
291func TestGetBundle_PermanentBackoffFail(t *testing.T) {

Callers

nothing calls this directly

Calls 4

getBundleMethod · 0.95
NewTestHandlerFunction · 0.92
NewImmutableSafeURLFunction · 0.92
EqualMethod · 0.80

Tested by

no test coverage detected