[] metabase: Write unit tests for checking the absence of payloads

Metabase should not store payloads of objects. Set payload in generated test
object. Ascertain that objects returned by Get method have no payload.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-03-22 19:44:57 +03:00 committed by Alex Vanin
parent 8bdffa2dc5
commit e3f8470d7a
2 changed files with 6 additions and 5 deletions
pkg/local_object_storage/metabase

View file

@ -95,6 +95,7 @@ func generateRawObjectWithCID(t *testing.T, cid *container.ID) *object.RawObject
obj.SetVersion(version)
obj.SetPayloadChecksum(csum)
obj.SetPayloadHomomorphicHash(csumTZ)
obj.SetPayload([]byte{1, 2, 3, 4, 5})
return obj
}

View file

@ -31,7 +31,7 @@ func TestDB_Get(t *testing.T) {
newObj, err := meta.Get(db, raw.Object().Address())
require.NoError(t, err)
require.Equal(t, raw.Object(), newObj)
require.Equal(t, raw.CutPayload().Object(), newObj)
})
t.Run("put tombstone object", func(t *testing.T) {
@ -43,7 +43,7 @@ func TestDB_Get(t *testing.T) {
newObj, err := meta.Get(db, raw.Object().Address())
require.NoError(t, err)
require.Equal(t, raw.Object(), newObj)
require.Equal(t, raw.CutPayload().Object(), newObj)
})
t.Run("put storage group object", func(t *testing.T) {
@ -55,7 +55,7 @@ func TestDB_Get(t *testing.T) {
newObj, err := meta.Get(db, raw.Object().Address())
require.NoError(t, err)
require.Equal(t, raw.Object(), newObj)
require.Equal(t, raw.CutPayload().Object(), newObj)
})
t.Run("put virtual object", func(t *testing.T) {
@ -87,11 +87,11 @@ func TestDB_Get(t *testing.T) {
newParent, err := meta.GetRaw(db, parent.Object().Address(), false)
require.NoError(t, err)
require.True(t, binaryEqual(parent.Object(), newParent))
require.True(t, binaryEqual(parent.CutPayload().Object(), newParent))
newChild, err := meta.GetRaw(db, child.Object().Address(), true)
require.NoError(t, err)
require.True(t, binaryEqual(child.Object(), newChild))
require.True(t, binaryEqual(child.CutPayload().Object(), newChild))
})
}