[#1175] metabase: Return status error on Lock of irregular object

Make `DB.Lock` to return `apistatus.IrregularObjectLock` if at least one
of the locked objects is irregular (not of type REGULAR).

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-02-16 01:17:40 +03:00 committed by LeL
parent 23fcacd3f2
commit b585791d6e
2 changed files with 7 additions and 7 deletions

View file

@ -4,6 +4,7 @@ import (
"testing"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
@ -36,12 +37,14 @@ func TestDB_Lock(t *testing.T) {
err := meta.Put(db, obj, nil)
require.NoError(t, err, typ)
var e apistatus.IrregularObjectLock
// try to lock it
err = db.Lock(cnr, *oidtest.ID(), []oid.ID{*obj.ID()})
if typ == object.TypeRegular {
require.NoError(t, err, typ)
} else {
require.ErrorIs(t, err, meta.ErrLockIrregularObject, typ)
require.ErrorAs(t, err, &e, typ)
}
}
})