Fix OneDrive and Kopia Wrapper test flakes (#1662)
## Description Minor fixes for flakey tests: * Dedupe OneDrive folders by checking IDs. Should help remove some test flakes. * Weaken checks on kopia snapshot manager tests as they use maps with indeterminate iteration orders ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [ ] 🐹 Trivial/Minor ## Issue(s) * closes #1660 * closes #1657 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
c9a3884289
commit
af977f46ca
@ -275,7 +275,7 @@ func GetAllFolders(
|
||||
return nil, errors.Wrap(err, "getting OneDrive folders")
|
||||
}
|
||||
|
||||
res := []*Displayable{}
|
||||
folders := map[string]*Displayable{}
|
||||
|
||||
for _, d := range drives {
|
||||
err = collectItems(
|
||||
@ -294,13 +294,18 @@ func GetAllFolders(
|
||||
continue
|
||||
}
|
||||
|
||||
if item.GetId() == nil || len(*item.GetId()) == 0 {
|
||||
logger.Ctx(ctx).Warn("folder without ID")
|
||||
continue
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(*item.GetName(), prefix) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Add the item instead of the folder because the item has more
|
||||
// functionality.
|
||||
res = append(res, &Displayable{item})
|
||||
folders[*item.GetId()] = &Displayable{item}
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -311,6 +316,12 @@ func GetAllFolders(
|
||||
}
|
||||
}
|
||||
|
||||
res := make([]*Displayable, 0, len(folders))
|
||||
|
||||
for _, f := range folders {
|
||||
res = append(res, f)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
|
||||
@ -526,8 +526,6 @@ func (suite *SnapshotFetchUnitSuite) TestFetchPrevSnapshotsWorksWithErrors() {
|
||||
),
|
||||
}
|
||||
|
||||
expected := []*snapshot.Manifest{mockData[2].man}
|
||||
|
||||
msm := &mockErrorSnapshotManager{
|
||||
sm: &mockSnapshotManager{
|
||||
data: mockData,
|
||||
@ -536,5 +534,7 @@ func (suite *SnapshotFetchUnitSuite) TestFetchPrevSnapshotsWorksWithErrors() {
|
||||
|
||||
snaps := fetchPrevSnapshotManifests(ctx, msm, input)
|
||||
|
||||
assert.ElementsMatch(t, expected, snaps)
|
||||
// Only 1 snapshot should be chosen because the other two attempts fail.
|
||||
// However, which one is returned is non-deterministic because maps are used.
|
||||
assert.Len(t, snaps, 1)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user