satellite/metabase/metabasetest: sort results
Deletion results are not guaranteed to be sorted, hence we need to sort them before comparing. Change-Id: I6b571dd812d4256327c6c64fff74c780c62b2948
This commit is contained in:
parent
6e6051b172
commit
6161436d8b
@ -63,6 +63,12 @@ func sortRawSegments(segments []metabase.RawSegment) {
|
||||
})
|
||||
}
|
||||
|
||||
func sortDeletedSegments(segments []metabase.DeletedSegmentInfo) {
|
||||
sort.Slice(segments, func(i, j int) bool {
|
||||
return bytes.Compare(segments[i].RootPieceID[:], segments[j].RootPieceID[:]) < 0
|
||||
})
|
||||
}
|
||||
|
||||
func checkError(t testing.TB, err error, errClass *errs.Class, errText string) {
|
||||
if errClass != nil {
|
||||
require.True(t, errClass.Has(err), "expected an error %v got %v", *errClass, err)
|
||||
|
@ -385,6 +385,12 @@ func (step DeleteObjectExactVersion) Check(ctx *testcontext.Context, t testing.T
|
||||
result, err := db.DeleteObjectExactVersion(ctx, step.Opts)
|
||||
checkError(t, err, step.ErrClass, step.ErrText)
|
||||
|
||||
sortObjects(result.Objects)
|
||||
sortObjects(step.Result.Objects)
|
||||
|
||||
sortDeletedSegments(result.Segments)
|
||||
sortDeletedSegments(step.Result.Segments)
|
||||
|
||||
diff := cmp.Diff(step.Result, result, cmpopts.EquateApproxTime(5*time.Second))
|
||||
require.Zero(t, diff)
|
||||
}
|
||||
@ -402,6 +408,12 @@ func (step DeletePendingObject) Check(ctx *testcontext.Context, t testing.TB, db
|
||||
result, err := db.DeletePendingObject(ctx, step.Opts)
|
||||
checkError(t, err, step.ErrClass, step.ErrText)
|
||||
|
||||
sortObjects(result.Objects)
|
||||
sortObjects(step.Result.Objects)
|
||||
|
||||
sortDeletedSegments(result.Segments)
|
||||
sortDeletedSegments(step.Result.Segments)
|
||||
|
||||
diff := cmp.Diff(step.Result, result, cmpopts.EquateApproxTime(5*time.Second))
|
||||
require.Zero(t, diff)
|
||||
}
|
||||
@ -419,6 +431,12 @@ func (step DeleteObjectLatestVersion) Check(ctx *testcontext.Context, t testing.
|
||||
result, err := db.DeleteObjectLatestVersion(ctx, step.Opts)
|
||||
checkError(t, err, step.ErrClass, step.ErrText)
|
||||
|
||||
sortObjects(result.Objects)
|
||||
sortObjects(step.Result.Objects)
|
||||
|
||||
sortDeletedSegments(result.Segments)
|
||||
sortDeletedSegments(step.Result.Segments)
|
||||
|
||||
diff := cmp.Diff(step.Result, result, cmpopts.EquateApproxTime(5*time.Second))
|
||||
require.Zero(t, diff)
|
||||
}
|
||||
@ -436,6 +454,12 @@ func (step DeleteObjectAnyStatusAllVersions) Check(ctx *testcontext.Context, t t
|
||||
result, err := db.DeleteObjectAnyStatusAllVersions(ctx, step.Opts)
|
||||
checkError(t, err, step.ErrClass, step.ErrText)
|
||||
|
||||
sortObjects(result.Objects)
|
||||
sortObjects(step.Result.Objects)
|
||||
|
||||
sortDeletedSegments(result.Segments)
|
||||
sortDeletedSegments(step.Result.Segments)
|
||||
|
||||
diff := cmp.Diff(step.Result, result, cmpopts.EquateApproxTime(5*time.Second))
|
||||
require.Zero(t, diff)
|
||||
}
|
||||
@ -456,6 +480,9 @@ func (step DeleteObjectsAllVersions) Check(ctx *testcontext.Context, t testing.T
|
||||
sortObjects(result.Objects)
|
||||
sortObjects(step.Result.Objects)
|
||||
|
||||
sortDeletedSegments(result.Segments)
|
||||
sortDeletedSegments(step.Result.Segments)
|
||||
|
||||
diff := cmp.Diff(step.Result, result, cmpopts.EquateApproxTime(5*time.Second))
|
||||
require.Zero(t, diff)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user