forked from TrueCloudLab/frostfs-api-go
[#302] pkg/netmap: Document default values set in NewNodeInfo
and NewNodeAttribute
Document field values of instance constructed via `NewNodeInfo` and `NewNodeAttribute`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
05f48d9394
commit
df4d610fad
2 changed files with 57 additions and 0 deletions
|
@ -202,3 +202,41 @@ func TestNodeInfoEncoding(t *testing.T) {
|
|||
require.Equal(t, i, i2)
|
||||
})
|
||||
}
|
||||
|
||||
func TestNewNodeAttribute(t *testing.T) {
|
||||
t.Run("default values", func(t *testing.T) {
|
||||
attr := NewNodeAttribute()
|
||||
|
||||
// check initial values
|
||||
require.Empty(t, attr.Key())
|
||||
require.Empty(t, attr.Value())
|
||||
require.Nil(t, attr.ParentKeys())
|
||||
|
||||
// convert to v2 message
|
||||
attrV2 := attr.ToV2()
|
||||
|
||||
require.Empty(t, attrV2.GetKey())
|
||||
require.Empty(t, attrV2.GetValue())
|
||||
require.Nil(t, attrV2.GetParents())
|
||||
})
|
||||
}
|
||||
|
||||
func TestNewNodeInfo(t *testing.T) {
|
||||
t.Run("default values", func(t *testing.T) {
|
||||
ni := NewNodeInfo()
|
||||
|
||||
// check initial values
|
||||
require.Nil(t, ni.PublicKey())
|
||||
require.Empty(t, ni.Address())
|
||||
require.Nil(t, ni.Attributes())
|
||||
require.Zero(t, ni.State())
|
||||
|
||||
// convert to v2 message
|
||||
niV2 := ni.ToV2()
|
||||
|
||||
require.Nil(t, niV2.GetPublicKey())
|
||||
require.Empty(t, niV2.GetAddress())
|
||||
require.Nil(t, niV2.GetAttributes())
|
||||
require.EqualValues(t, netmap.UnspecifiedState, niV2.GetState())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue