diff --git a/pkg/netmap/selector.go b/pkg/netmap/selector.go index 72ae857c..b4100d47 100644 --- a/pkg/netmap/selector.go +++ b/pkg/netmap/selector.go @@ -156,6 +156,13 @@ func (c *Context) getSelectionBase(s *Selector) []nodeAttrPair { } // NewSelector creates and returns new Selector instance. +// +// Defaults: +// - name: ""; +// - attribute: ""; +// - filter: ""; +// - clause: ClauseUnspecified; +// - count: 0. func NewSelector() *Selector { return NewSelectorFromV2(new(netmap.Selector)) } diff --git a/pkg/netmap/selector_test.go b/pkg/netmap/selector_test.go index f628d0b5..6854288b 100644 --- a/pkg/netmap/selector_test.go +++ b/pkg/netmap/selector_test.go @@ -507,3 +507,25 @@ func TestNewSelectorFromV2(t *testing.T) { require.Equal(t, sV2, s.ToV2()) }) } + +func TestNewSelector(t *testing.T) { + t.Run("default values", func(t *testing.T) { + s := NewSelector() + + // check initial values + require.Zero(t, s.Count()) + require.Equal(t, ClauseUnspecified, s.Clause()) + require.Empty(t, s.Attribute()) + require.Empty(t, s.Name()) + require.Empty(t, s.Filter()) + + // convert to v2 message + sV2 := s.ToV2() + + require.Zero(t, sV2.GetCount()) + require.Equal(t, netmap.UnspecifiedClause, sV2.GetClause()) + require.Empty(t, sV2.GetAttribute()) + require.Empty(t, sV2.GetName()) + require.Empty(t, sV2.GetFilter()) + }) +}