[#209] pkg/object: Support splitID field in SDK library

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-11-24 20:15:12 +03:00 committed by Alex Vanin
parent b9778464b9
commit 6b0bd42f25
3 changed files with 34 additions and 0 deletions

View file

@ -110,6 +110,11 @@ func (o *RawObject) SetChildren(v ...*ID) {
o.setChildren(v...)
}
// SetSplitID sets split identifier for the split object.
func (o *RawObject) SetSplitID(v []byte) {
o.setSplitID(v)
}
// SetParentID sets identifier of the parent object.
func (o *RawObject) SetParentID(v *ID) {
o.setParentID(v)

View file

@ -5,6 +5,7 @@ import (
"crypto/sha256"
"testing"
"github.com/google/uuid"
"github.com/nspcc-dev/neofs-api-go/pkg"
"github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
@ -190,6 +191,19 @@ func TestRawObject_SetChildren(t *testing.T) {
require.Equal(t, []*ID{id1, id2}, obj.Children())
}
func TestRawObject_SetSplitID(t *testing.T) {
obj := NewRaw()
require.Nil(t, obj.SplitID())
splitID, err := uuid.New().MarshalBinary()
require.NoError(t, err)
obj.SetSplitID(splitID)
require.Equal(t, obj.SplitID(), splitID)
}
func TestRawObject_SetParent(t *testing.T) {
obj := NewRaw()

View file

@ -251,6 +251,21 @@ func (o *rwObject) setChildren(v ...*ID) {
})
}
// SplitID return split identity of split object. If object is not split
// returns nil.
func (o *rwObject) SplitID() []byte {
return (*object.Object)(o).
GetHeader().
GetSplit().
GetSplitID()
}
func (o *rwObject) setSplitID(id []byte) {
o.setSplitFields(func(split *object.SplitHeader) {
split.SetSplitID(id)
})
}
// ParentID returns identifier of the parent object.
func (o *rwObject) ParentID() *ID {
return NewIDFromV2(