[#302] pkg/netmap: Document default values set in NewReplica
Document field values of instance constructed via `NewReplica`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
fb591f5fac
commit
af1742b48a
2 changed files with 20 additions and 0 deletions
|
@ -8,6 +8,10 @@ import (
|
|||
type Replica netmap.Replica
|
||||
|
||||
// NewReplica creates and returns new Replica instance.
|
||||
//
|
||||
// Defaults:
|
||||
// - count: 0;
|
||||
// - selector: "".
|
||||
func NewReplica() *Replica {
|
||||
return NewReplicaFromV2(new(netmap.Replica))
|
||||
}
|
||||
|
|
|
@ -81,3 +81,19 @@ func TestReplica_ToV2(t *testing.T) {
|
|||
require.Nil(t, x.ToV2())
|
||||
})
|
||||
}
|
||||
|
||||
func TestNewReplica(t *testing.T) {
|
||||
t.Run("default values", func(t *testing.T) {
|
||||
r := NewReplica()
|
||||
|
||||
// check initial values
|
||||
require.Zero(t, r.Count())
|
||||
require.Empty(t, r.Selector())
|
||||
|
||||
// convert to v2 message
|
||||
rV2 := r.ToV2()
|
||||
|
||||
require.Zero(t, rV2.GetCount())
|
||||
require.Empty(t, rV2.GetSelector())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue