forked from TrueCloudLab/frostfs-api-go
[#302] pkg/netmap: Document default values set in NewSelector
Document field values of instance constructed via `NewSelector`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
c47d1fb26b
commit
2307c8f8f7
2 changed files with 29 additions and 0 deletions
|
@ -156,6 +156,13 @@ func (c *Context) getSelectionBase(s *Selector) []nodeAttrPair {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSelector creates and returns new Selector instance.
|
// NewSelector creates and returns new Selector instance.
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - name: "";
|
||||||
|
// - attribute: "";
|
||||||
|
// - filter: "";
|
||||||
|
// - clause: ClauseUnspecified;
|
||||||
|
// - count: 0.
|
||||||
func NewSelector() *Selector {
|
func NewSelector() *Selector {
|
||||||
return NewSelectorFromV2(new(netmap.Selector))
|
return NewSelectorFromV2(new(netmap.Selector))
|
||||||
}
|
}
|
||||||
|
|
|
@ -507,3 +507,25 @@ func TestNewSelectorFromV2(t *testing.T) {
|
||||||
require.Equal(t, sV2, s.ToV2())
|
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())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue