frostfs-s3-gw/internal/frostfs/crdt/gset_test.go
Marina Biryukova b4c7b11cde Add retry when node not found
Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
2023-09-26 14:26:33 +03:00

38 lines
1.2 KiB
Go

package crdt
import (
"testing"
oid "git.frostfs.info/mbiryukova/frostfs-sdk-go/object/id"
"github.com/stretchr/testify/require"
)
func TestObjectVersionsSort(t *testing.T) {
t.Run("sort by epoch", func(t *testing.T) {
versions := NewObjectVersions("test")
versions.AppendVersion(&ObjectVersion{CreationEpoch: 3})
versions.AppendVersion(&ObjectVersion{CreationEpoch: 1})
versions.AppendVersion(&ObjectVersion{CreationEpoch: 2})
last := versions.GetLast()
require.Equal(t, uint64(3), last.CreationEpoch)
})
t.Run("sort by oids", func(t *testing.T) {
versions := NewObjectVersions("test")
versions.AppendVersion(&ObjectVersion{CreationEpoch: 3, OjbID: getTestOID(2)})
versions.AppendVersion(&ObjectVersion{CreationEpoch: 3, OjbID: getTestOID(1)})
versions.AppendVersion(&ObjectVersion{CreationEpoch: 1, OjbID: getTestOID(3)})
versions.AppendVersion(&ObjectVersion{CreationEpoch: 2, OjbID: getTestOID(4)})
last := versions.GetLast()
require.Equal(t, uint64(3), last.CreationEpoch)
require.Equal(t, getTestOID(2).String(), last.VersionID())
})
}
func getTestOID(val byte) oid.ID {
var res oid.ID
res.SetSHA256([32]byte{val})
return res
}