forked from TrueCloudLab/frostfs-api-go
[#164] sdk/object: Return nil parent if parent fields are empty
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
ae81f4584e
commit
9799e5d48c
2 changed files with 14 additions and 2 deletions
|
@ -186,8 +186,13 @@ func TestRawObject_SetChildren(t *testing.T) {
|
|||
func TestRawObject_SetParent(t *testing.T) {
|
||||
obj := NewRaw()
|
||||
|
||||
require.Nil(t, obj.GetParent())
|
||||
|
||||
par := NewRaw()
|
||||
par.SetID(randID(t))
|
||||
par.SetContainerID(container.NewID())
|
||||
par.SetSignature(pkg.NewSignature())
|
||||
|
||||
parObj := par.Object()
|
||||
|
||||
obj.SetParent(parObj)
|
||||
|
|
|
@ -273,10 +273,17 @@ func (o *rwObject) GetParent() *Object {
|
|||
GetHeader().
|
||||
GetSplit()
|
||||
|
||||
parSig := h.GetParentSignature()
|
||||
parHdr := h.GetParentHeader()
|
||||
|
||||
if parSig == nil && parHdr == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
oV2 := new(object.Object)
|
||||
oV2.SetObjectID(h.GetParent())
|
||||
oV2.SetSignature(h.GetParentSignature())
|
||||
oV2.SetHeader(h.GetParentHeader())
|
||||
oV2.SetSignature(parSig)
|
||||
oV2.SetHeader(parHdr)
|
||||
|
||||
return NewFromV2(oV2)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue