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:
Abin Simon 2023-03-06 10:56:43 +05:30 committed by GitHub
parent 5255517067
commit 74840f035d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import (
"net/http"
"net/url"
"os"
"strings"
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
"github.com/pkg/errors"
@ -23,7 +24,7 @@ const (
errCodeItemNotFound = "ErrorItemNotFound"
errCodeItemNotFoundShort = "itemNotFound"
errCodeEmailFolderNotFound = "ErrorSyncFolderNotFound"
errCodeResyncRequired = "ResyncRequired"
errCodeResyncRequired = "ResyncRequired" // alt: resyncRequired
errCodeSyncFolderNotFound = "ErrorSyncFolderNotFound"
errCodeSyncStateNotFound = "SyncStateNotFound"
errCodeResourceNotFound = "ResourceNotFound"
@ -187,7 +188,12 @@ func hasErrorCode(err error, codes ...string) bool {
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

View File

@ -104,6 +104,17 @@ func (suite *GraphErrorsUnitSuite) TestIsErrInvalidDelta() {
err: odErr(errCodeResyncRequired),
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 {
suite.Run(test.name, func() {