Graph ResyncRequired error can also manifest as resyncRequired (#2688)
The only change is that the first letter is now small. <!-- Insert PR description--> --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
5255517067
commit
74840f035d
@ -6,6 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -23,7 +24,7 @@ const (
|
|||||||
errCodeItemNotFound = "ErrorItemNotFound"
|
errCodeItemNotFound = "ErrorItemNotFound"
|
||||||
errCodeItemNotFoundShort = "itemNotFound"
|
errCodeItemNotFoundShort = "itemNotFound"
|
||||||
errCodeEmailFolderNotFound = "ErrorSyncFolderNotFound"
|
errCodeEmailFolderNotFound = "ErrorSyncFolderNotFound"
|
||||||
errCodeResyncRequired = "ResyncRequired"
|
errCodeResyncRequired = "ResyncRequired" // alt: resyncRequired
|
||||||
errCodeSyncFolderNotFound = "ErrorSyncFolderNotFound"
|
errCodeSyncFolderNotFound = "ErrorSyncFolderNotFound"
|
||||||
errCodeSyncStateNotFound = "SyncStateNotFound"
|
errCodeSyncStateNotFound = "SyncStateNotFound"
|
||||||
errCodeResourceNotFound = "ResourceNotFound"
|
errCodeResourceNotFound = "ResourceNotFound"
|
||||||
@ -187,7 +188,12 @@ func hasErrorCode(err error, codes ...string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return slices.Contains(codes, *oDataError.GetError().GetCode())
|
lcodes := []string{}
|
||||||
|
for _, c := range codes {
|
||||||
|
lcodes = append(lcodes, strings.ToLower(c))
|
||||||
|
}
|
||||||
|
|
||||||
|
return slices.Contains(lcodes, strings.ToLower(*oDataError.GetError().GetCode()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrData is a helper function that extracts ODataError metadata from
|
// ErrData is a helper function that extracts ODataError metadata from
|
||||||
|
|||||||
@ -104,6 +104,17 @@ func (suite *GraphErrorsUnitSuite) TestIsErrInvalidDelta() {
|
|||||||
err: odErr(errCodeResyncRequired),
|
err: odErr(errCodeResyncRequired),
|
||||||
expect: assert.True,
|
expect: assert.True,
|
||||||
},
|
},
|
||||||
|
// next two tests are to make sure the checks are case insensitive
|
||||||
|
{
|
||||||
|
name: "resync-required oDataErr camelcase",
|
||||||
|
err: odErr("resyncRequired"),
|
||||||
|
expect: assert.True,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "resync-required oDataErr lowercase",
|
||||||
|
err: odErr("resyncrequired"),
|
||||||
|
expect: assert.True,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.Run(test.name, func() {
|
suite.Run(test.name, func() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user