frostfs-node/pkg/local_object_storage/shard/inhume_test.go
Ayrat Arifullin 9808dec591
Some checks failed
ci/woodpecker/push/pre-commit Pipeline failed
[#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>
2023-03-23 08:19:15 +00:00

55 lines
1.4 KiB
Go

package shard_test
import (
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
"github.com/stretchr/testify/require"
)
func TestShard_Inhume(t *testing.T) {
t.Run("without write cache", func(t *testing.T) {
testShardInhume(t, false)
})
t.Run("with write cache", func(t *testing.T) {
testShardInhume(t, true)
})
}
func testShardInhume(t *testing.T, hasWriteCache bool) {
sh := newShard(t, hasWriteCache)
defer releaseShard(sh, t)
cnr := cidtest.ID()
obj := testutil.GenerateObjectWithCID(cnr)
testutil.AddAttribute(obj, "foo", "bar")
ts := testutil.GenerateObjectWithCID(cnr)
var putPrm shard.PutPrm
putPrm.SetObject(obj)
var inhPrm shard.InhumePrm
inhPrm.SetTarget(object.AddressOf(ts), object.AddressOf(obj))
var getPrm shard.GetPrm
getPrm.SetAddress(object.AddressOf(obj))
_, err := sh.Put(putPrm)
require.NoError(t, err)
_, err = testGet(t, sh, getPrm, hasWriteCache)
require.NoError(t, err)
_, err = sh.Inhume(inhPrm)
require.NoError(t, err)
_, err = sh.Get(getPrm)
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
}