frostfs-node/pkg/local_object_storage/metabase/control_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

51 lines
1.1 KiB
Go

package meta_test
import (
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
"github.com/stretchr/testify/require"
)
func TestReset(t *testing.T) {
db := newDB(t)
err := db.Reset()
require.NoError(t, err)
obj := generateObject(t)
addr := object.AddressOf(obj)
addrToInhume := oidtest.Address()
assertExists := func(addr oid.Address, expExists bool, assertErr func(error) bool) {
exists, err := meta.Exists(db, addr)
if assertErr != nil {
require.True(t, assertErr(err))
} else {
require.NoError(t, err)
}
require.Equal(t, expExists, exists)
}
assertExists(addr, false, nil)
assertExists(addrToInhume, false, nil)
err = putBig(db, obj)
require.NoError(t, err)
err = meta.Inhume(db, addrToInhume, oidtest.Address())
require.NoError(t, err)
assertExists(addr, true, nil)
assertExists(addrToInhume, false, meta.IsErrRemoved)
err = db.Reset()
require.NoError(t, err)
assertExists(addr, false, nil)
assertExists(addr, false, nil)
}