[#302] pkg/object: Document default values set in NewAddress
Document field values of instance constructed via `NewAddress`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
c978fa0e21
commit
5fda8ef796
2 changed files with 20 additions and 0 deletions
|
@ -28,6 +28,10 @@ func NewAddressFromV2(aV2 *refs.Address) *Address {
|
|||
// NewAddress creates and initializes blank Address.
|
||||
//
|
||||
// Works similar as NewAddressFromV2(new(Address)).
|
||||
//
|
||||
// Defaults:
|
||||
// - cid: nil;
|
||||
// - oid: nil.
|
||||
func NewAddress() *Address {
|
||||
return NewAddressFromV2(new(refs.Address))
|
||||
}
|
||||
|
|
|
@ -101,3 +101,19 @@ func TestAddress_ToV2(t *testing.T) {
|
|||
require.Nil(t, x.ToV2())
|
||||
})
|
||||
}
|
||||
|
||||
func TestNewAddress(t *testing.T) {
|
||||
t.Run("default values", func(t *testing.T) {
|
||||
a := NewAddress()
|
||||
|
||||
// check initial values
|
||||
require.Nil(t, a.ContainerID())
|
||||
require.Nil(t, a.ObjectID())
|
||||
|
||||
// convert to v2 message
|
||||
aV2 := a.ToV2()
|
||||
|
||||
require.Nil(t, aV2.GetContainerID())
|
||||
require.Nil(t, aV2.GetObjectID())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue