[#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:
Pavel Karpy 2021-06-08 18:29:16 +03:00 committed by Alex Vanin
parent fb591f5fac
commit af1742b48a
2 changed files with 20 additions and 0 deletions

View file

@ -8,6 +8,10 @@ import (
type Replica netmap.Replica type Replica netmap.Replica
// NewReplica creates and returns new Replica instance. // NewReplica creates and returns new Replica instance.
//
// Defaults:
// - count: 0;
// - selector: "".
func NewReplica() *Replica { func NewReplica() *Replica {
return NewReplicaFromV2(new(netmap.Replica)) return NewReplicaFromV2(new(netmap.Replica))
} }

View file

@ -81,3 +81,19 @@ func TestReplica_ToV2(t *testing.T) {
require.Nil(t, x.ToV2()) 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())
})
}