(t *testing.T)
| 354 | } |
| 355 | |
| 356 | func 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 | |
| 385 | func TestGetAttestationsRetriesRESTWithNextError(t *testing.T) { |
| 386 | originalRetryInterval := getAttestationRetryInterval |
nothing calls this directly
no test coverage detected