forked from TrueCloudLab/frostfs-api-go
[#302] pkg/netmap: Document default values set in NewNetworkInfo
Document field values of instance constructed via `NewNetworkInfo`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
6142a352da
commit
19cf3c2d0b
2 changed files with 18 additions and 0 deletions
|
@ -16,6 +16,10 @@ func NewNetworkInfoFromV2(iV2 *netmap.NetworkInfo) *NetworkInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNetworkInfo creates and initializes blank NetworkInfo.
|
// NewNetworkInfo creates and initializes blank NetworkInfo.
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - curEpoch: 0;
|
||||||
|
// - magicNum: 0.
|
||||||
func NewNetworkInfo() *NetworkInfo {
|
func NewNetworkInfo() *NetworkInfo {
|
||||||
return NewNetworkInfoFromV2(new(netmap.NetworkInfo))
|
return NewNetworkInfoFromV2(new(netmap.NetworkInfo))
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,3 +65,17 @@ func TestNetworkInfo_ToV2(t *testing.T) {
|
||||||
require.Nil(t, x.ToV2())
|
require.Nil(t, x.ToV2())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewNetworkInfo(t *testing.T) {
|
||||||
|
ni := NewNetworkInfo()
|
||||||
|
|
||||||
|
// check initial values
|
||||||
|
require.Zero(t, ni.CurrentEpoch())
|
||||||
|
require.Zero(t, ni.MagicNumber())
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
niV2 := ni.ToV2()
|
||||||
|
|
||||||
|
require.Zero(t, niV2.GetCurrentEpoch())
|
||||||
|
require.Zero(t, niV2.GetMagicNumber())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue