From b5ddab7c6449b375cb1a38e22bc504a8856f8b2d Mon Sep 17 00:00:00 2001 From: Ashlie Martinez Date: Tue, 29 Aug 2023 14:24:54 -0700 Subject: [PATCH] Add test explicitly for quota status Ensure that if the we see a quota error that we actually return the status we think we should. --- src/pkg/services/m365/api/users_test.go | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/pkg/services/m365/api/users_test.go b/src/pkg/services/m365/api/users_test.go index 107d12fa7..490c7e908 100644 --- a/src/pkg/services/m365/api/users_test.go +++ b/src/pkg/services/m365/api/users_test.go @@ -7,6 +7,7 @@ import ( "github.com/h2non/gock" "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/m365/graph" @@ -250,3 +251,29 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() { }) } } + +func (suite *UsersIntgSuite) TestUsers_GetInfo_QuotaExceeded() { + t := suite.T() + ctx, flush := tester.NewContext(t) + + defer flush() + defer gock.Off() + + gock.EnableNetworking() + gock.New(graphAPIHostURL). + // Wildcard match on the inbox folder ID. + Get(v1APIURLPath("users", suite.its.userID, "mailFolders", "(.*)", "messages", "delta")). + Reply(403). + SetHeaders( + map[string]string{ + "Content-Type": "application/json; odata.metadata=minimal; " + + "odata.streaming=true; IEEE754Compatible=false; charset=utf-8", + }, + ). + BodyString(`{"error":{"code":"ErrorQuotaExceeded","message":"The process failed to get the correct properties."}}`) + + output, err := suite.its.gockAC.Users().GetInfo(ctx, suite.its.userID) + require.NoError(t, err, clues.ToCore(err)) + + assert.True(t, output.Mailbox.QuotaExceeded) +}