forked from TrueCloudLab/frostfs-api-go
Merge pull request #77 from nspcc-dev/fix-object-token-copy
object: add Token header case to CopyTo
This commit is contained in:
commit
b6e6aa7238
2 changed files with 27 additions and 0 deletions
|
@ -251,6 +251,12 @@ func (m *Object) CopyTo(o *Object) {
|
||||||
HomoHash: v.HomoHash,
|
HomoHash: v.HomoHash,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
case *Header_Token:
|
||||||
|
o.Headers[i] = Header{
|
||||||
|
Value: &Header_Token{
|
||||||
|
Token: v.Token,
|
||||||
|
},
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
o.Headers[i] = *proto.Clone(&m.Headers[i]).(*Header)
|
o.Headers[i] = *proto.Clone(&m.Headers[i]).(*Header)
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,3 +178,24 @@ Object:
|
||||||
require.NoError(t, Stringify(buf, obj))
|
require.NoError(t, Stringify(buf, obj))
|
||||||
require.Equal(t, res, buf.String())
|
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