storagenode/blobstore/filestore: fix flaky TestTrashAndRestore

The result sorting was not correct causing occasional failures.

Fixes https://github.com/storj/storj/issues/6511

Change-Id: I09242846eda7c40198e7375ce218cb7026f9e7e4
This commit is contained in:
Egon Elbre 2023-11-15 16:54:28 +02:00 committed by Clement Sam
parent 25262d62f3
commit 1105deba48

View File

@ -783,9 +783,13 @@ func TestTrashAndRestore(t *testing.T) {
expKeysRestored = append(expKeysRestored, ref.key)
}
}
sort.Slice(expKeysRestored, func(i int, j int) bool { return expKeysRestored[i][0] < expKeysRestored[j][0] })
sort.Slice(expKeysRestored, func(i int, j int) bool {
return bytes.Compare(expKeysRestored[i], expKeysRestored[j]) < 0
})
restoredKeys, err := store.RestoreTrash(ctx, namespaces[0].namespace)
sort.Slice(restoredKeys, func(i int, j int) bool { return restoredKeys[i][0] < restoredKeys[j][0] })
sort.Slice(restoredKeys, func(i int, j int) bool {
return bytes.Compare(restoredKeys[i], restoredKeys[j]) < 0
})
require.NoError(t, err)
assert.Equal(t, expKeysRestored, restoredKeys)