frostfs-node/pkg/local_object_storage/shard/inhume_test.go
Leonard Lyubich 1c30414a6c [#1454] Upgrade NeoFS SDK Go module with new IDs
Core changes:
 * avoid package-colliding variable naming
 * avoid using pointers to IDs where unnecessary
 * avoid using `idSDK` import alias pattern
 * use `EncodeToString` for protocol string calculation and `String` for
  printing

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-06-01 17:41:45 +03:00

54 lines
1.2 KiB
Go

package shard_test
import (
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cidtest "github.com/nspcc-dev/neofs-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 := generateObjectWithCID(t, cnr)
addAttribute(obj, "foo", "bar")
ts := generateObjectWithCID(t, cnr)
putPrm := new(shard.PutPrm)
putPrm.WithObject(obj)
inhPrm := new(shard.InhumePrm)
inhPrm.WithTarget(object.AddressOf(ts), object.AddressOf(obj))
getPrm := new(shard.GetPrm)
getPrm.WithAddress(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))
}