satellite/metabasetest: order RawSegments by streamID and position

Change-Id: I669c0c2361c2c7989c8e946eb1fbf2f52074ce0e
This commit is contained in:
Fadila Khadar 2022-02-18 01:14:50 +01:00 committed by Fadila
parent 2d4760fd09
commit 332e6afed8
2 changed files with 7 additions and 9 deletions

View File

@ -352,11 +352,6 @@ func TestFinishCopyObject(t *testing.T) {
numberOfSegments := 10
copyStream := metabasetest.RandObjectStream()
// make sure segments are ordered as expected when checking database
if copyStream.StreamID.Less(obj.StreamID) {
obj, copyStream = copyStream, obj
}
originalObj := metabasetest.CreateTestObject{
CommitObject: &metabase.CommitObject{
ObjectStream: obj,

View File

@ -49,25 +49,28 @@ func (step Verify) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB
func sortObjects(objects []metabase.Object) {
sort.Slice(objects, func(i, j int) bool {
return bytes.Compare(objects[i].StreamID[:], objects[j].StreamID[:]) < 0
return objects[i].StreamID.Less(objects[j].StreamID)
})
}
func sortRawObjects(objects []metabase.RawObject) {
sort.Slice(objects, func(i, j int) bool {
return bytes.Compare(objects[i].StreamID[:], objects[j].StreamID[:]) < 0
return objects[i].StreamID.Less(objects[j].StreamID)
})
}
func sortRawSegments(segments []metabase.RawSegment) {
sort.Slice(segments, func(i, j int) bool {
return bytes.Compare(segments[i].StreamID[:], segments[j].StreamID[:]) < 0
if segments[i].StreamID == segments[j].StreamID {
return segments[i].Position.Less(segments[j].Position)
}
return segments[i].StreamID.Less(segments[j].StreamID)
})
}
func sortRawCopies(copies []metabase.RawCopy) {
sort.Slice(copies, func(i, j int) bool {
return bytes.Compare(copies[i].StreamID[:], copies[j].StreamID[:]) < 0
return copies[i].StreamID.Less(copies[j].StreamID)
})
}