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

Function TestGetAttestationsRetries

pkg/cmd/attestation/api/client_test.go:356–383  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

354}
355
356func TestGetAttestationsRetries(t *testing.T) {
357 getAttestationRetryInterval = 0
358
359 fetcher := mockDataGenerator{
360 NumUserAttestations: 5,
361 }
362
363 c := &LiveClient{
364 githubAPI: mockAPIClient{
365 OnRESTWithNext: fetcher.FlakyOnRESTSuccessWithNextPageHandler(),
366 },
367 externalHttpClient: &mockHttpClient{},
368 logger: io.NewTestHandler(),
369 }
370
371 testFetchParamsWithRepo.Limit = 30
372 attestations, err := c.GetByDigest(testFetchParamsWithRepo)
373 require.NoError(t, err)
374
375 // assert the error path was executed; because this is a paged
376 // request, it should have errored twice
377 fetcher.AssertNumberOfCalls(t, "FlakyOnRESTSuccessWithNextPage:error", 2)
378
379 // but we still successfully got the right data
380 require.Equal(t, len(attestations), 10)
381 bundle := (attestations)[0].Bundle
382 require.Equal(t, bundle.GetMediaType(), "application/vnd.dev.sigstore.bundle.v0.3+json")
383}
384
385func TestGetAttestationsRetriesRESTWithNextError(t *testing.T) {
386 originalRetryInterval := getAttestationRetryInterval

Callers

nothing calls this directly

Calls 4

GetByDigestMethod · 0.95
NewTestHandlerFunction · 0.92
EqualMethod · 0.80

Tested by

no test coverage detected