object: add Token header case to CopyTo
This commit is contained in:
parent
87d0efaad2
commit
dd2f568347
2 changed files with 27 additions and 0 deletions
|
@ -251,6 +251,12 @@ func (m *Object) CopyTo(o *Object) {
|
|||
HomoHash: v.HomoHash,
|
||||
},
|
||||
}
|
||||
case *Header_Token:
|
||||
o.Headers[i] = Header{
|
||||
Value: &Header_Token{
|
||||
Token: v.Token,
|
||||
},
|
||||
}
|
||||
default:
|
||||
o.Headers[i] = *proto.Clone(&m.Headers[i]).(*Header)
|
||||
}
|
||||
|
|
|
@ -178,3 +178,24 @@ Object:
|
|||
require.NoError(t, Stringify(buf, obj))
|
||||
require.Equal(t, res, buf.String())
|
||||
}
|
||||
|
||||
func TestObject_Copy(t *testing.T) {
|
||||
t.Run("token header", func(t *testing.T) {
|
||||
token := new(Token)
|
||||
token.SetID(service.TokenID{1, 2, 3})
|
||||
|
||||
obj := new(Object)
|
||||
|
||||
obj.AddHeader(&Header{
|
||||
Value: &Header_Token{
|
||||
Token: token,
|
||||
},
|
||||
})
|
||||
|
||||
cp := obj.Copy()
|
||||
|
||||
_, h := cp.LastHeader(HeaderType(TokenHdr))
|
||||
require.NotNil(t, h)
|
||||
require.Equal(t, token, h.GetValue().(*Header_Token).Token)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue