diff --git a/src/pkg/services/m365/api/events_pager_test.go b/src/pkg/services/m365/api/events_pager_test.go index 2da9140cf..7bfb8db54 100644 --- a/src/pkg/services/m365/api/events_pager_test.go +++ b/src/pkg/services/m365/api/events_pager_test.go @@ -18,6 +18,7 @@ import ( "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/tester/tconfig" "github.com/alcionai/corso/src/pkg/count" + "github.com/alcionai/corso/src/pkg/services/m365/api/graph" ) // --------------------------------------------------------------------------- @@ -107,13 +108,10 @@ func (suite *EventsPagerUnitSuite) TestEventsList() { Reply(http.StatusOK). JSON(validEventsListSingleNextLinkResponse) - // Number of retries and delay between retries is handled by a kiota - // middleware. We can change the default config parameters when setting - // up the mock in a later PR. gock.New(graphAPIHostURL). Get(nextLinkPath). AddMatcher(pageSizeMatcher(t, expectedPageSize)). - Times(4). + Times(2). // retry count is configured to 1 Reply(http.StatusServiceUnavailable). BodyString(""). Type("text/plain") @@ -241,7 +239,9 @@ func (suite *EventsPagerUnitSuite) TestEventsList() { creds, err := a.M365Config() require.NoError(t, err, clues.ToCore(err)) - client, err := gockClient(creds, count.New()) + // Run with a single retry since 503 retries are exponential and + // the test will take a long time to run. + client, err := gockClient(creds, count.New(), graph.MaxRetries(1)) require.NoError(t, err, clues.ToCore(err)) t.Cleanup(gock.Off) diff --git a/src/pkg/services/m365/api/helper_test.go b/src/pkg/services/m365/api/helper_test.go index cda1182f4..09eca18ae 100644 --- a/src/pkg/services/m365/api/helper_test.go +++ b/src/pkg/services/m365/api/helper_test.go @@ -23,13 +23,19 @@ import ( // GockClient produces a new exchange api client that can be // mocked using gock. -func gockClient(creds account.M365Config, counter *count.Bus) (Client, error) { - s, err := graph.NewGockService(creds, counter) +func gockClient( + creds account.M365Config, + counter *count.Bus, + opts ...graph.Option, +) (Client, error) { + s, err := graph.NewGockService(creds, counter, opts...) if err != nil { return Client{}, err } - li, err := graph.NewGockService(creds, counter, graph.NoTimeout()) + opts = append(opts, graph.NoTimeout()) + + li, err := graph.NewGockService(creds, counter, opts...) if err != nil { return Client{}, err }