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

Function TestGetBundle_SuccessfulRetry

pkg/cmd/attestation/api/client_test.go:276–291  ·  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

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