[#86] node: Move testing utils to one package

Move testing utils from tests in local_object_storage package to
unified testutil package

Signed-off-by: Airat Arifullin <aarifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2023-03-20 17:10:26 +03:00 committed by Gitea
parent 342e571d89
commit 9808dec591
41 changed files with 495 additions and 520 deletions

View file

@ -5,6 +5,7 @@ import (
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
@ -19,14 +20,14 @@ func TestDB_Exists(t *testing.T) {
db := newDB(t, meta.WithEpochState(epochState{currEpoch}))
t.Run("no object", func(t *testing.T) {
nonExist := generateObject(t)
nonExist := testutil.GenerateObject()
exists, err := metaExists(db, object.AddressOf(nonExist))
require.NoError(t, err)
require.False(t, exists)
})
t.Run("regular object", func(t *testing.T) {
regular := generateObject(t)
regular := testutil.GenerateObject()
err := putBig(db, regular)
require.NoError(t, err)
@ -45,7 +46,7 @@ func TestDB_Exists(t *testing.T) {
})
t.Run("tombstone object", func(t *testing.T) {
ts := generateObject(t)
ts := testutil.GenerateObject()
ts.SetType(objectSDK.TypeTombstone)
err := putBig(db, ts)
@ -57,7 +58,7 @@ func TestDB_Exists(t *testing.T) {
})
t.Run("storage group object", func(t *testing.T) {
sg := generateObject(t)
sg := testutil.GenerateObject()
sg.SetType(objectSDK.TypeStorageGroup)
err := putBig(db, sg)
@ -69,7 +70,7 @@ func TestDB_Exists(t *testing.T) {
})
t.Run("lock object", func(t *testing.T) {
lock := generateObject(t)
lock := testutil.GenerateObject()
lock.SetType(objectSDK.TypeLock)
err := putBig(db, lock)
@ -82,9 +83,9 @@ func TestDB_Exists(t *testing.T) {
t.Run("virtual object", func(t *testing.T) {
cnr := cidtest.ID()
parent := generateObjectWithCID(t, cnr)
parent := testutil.GenerateObjectWithCID(cnr)
child := generateObjectWithCID(t, cnr)
child := testutil.GenerateObjectWithCID(cnr)
child.SetParent(parent)
idParent, _ := parent.ID()
child.SetParentID(idParent)
@ -102,16 +103,16 @@ func TestDB_Exists(t *testing.T) {
cnr := cidtest.ID()
splitID := objectSDK.NewSplitID()
parent := generateObjectWithCID(t, cnr)
addAttribute(parent, "foo", "bar")
parent := testutil.GenerateObjectWithCID(cnr)
testutil.AddAttribute(parent, "foo", "bar")
child := generateObjectWithCID(t, cnr)
child := testutil.GenerateObjectWithCID(cnr)
child.SetParent(parent)
idParent, _ := parent.ID()
child.SetParentID(idParent)
child.SetSplitID(splitID)
link := generateObjectWithCID(t, cnr)
link := testutil.GenerateObjectWithCID(cnr)
link.SetParent(parent)
link.SetParentID(idParent)
idChild, _ := child.ID()