forked from TrueCloudLab/frostfs-node
[#438] 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:
parent
8bdffa2dc5
commit
e3f8470d7a
2 changed files with 6 additions and 5 deletions
pkg/local_object_storage/metabase
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue