forked from TrueCloudLab/frostfs-api-go
[#302] pkg/owner: Document default values set in NewID
Document field values of instance constructed via `NewID`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
12574469e5
commit
c00cdd407d
2 changed files with 22 additions and 0 deletions
|
@ -25,6 +25,9 @@ func NewIDFromV2(idV2 *refs.OwnerID) *ID {
|
||||||
// NewID creates and initializes blank ID.
|
// NewID creates and initializes blank ID.
|
||||||
//
|
//
|
||||||
// Works similar as NewIDFromV2(new(OwnerID)).
|
// Works similar as NewIDFromV2(new(OwnerID)).
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - value: nil.
|
||||||
func NewID() *ID {
|
func NewID() *ID {
|
||||||
return NewIDFromV2(new(refs.OwnerID))
|
return NewIDFromV2(new(refs.OwnerID))
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,3 +116,22 @@ func TestID_ToV2(t *testing.T) {
|
||||||
require.Nil(t, x.ToV2())
|
require.Nil(t, x.ToV2())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestID_String(t *testing.T) {
|
||||||
|
t.Run("nil", func(t *testing.T) {
|
||||||
|
id := NewID()
|
||||||
|
|
||||||
|
require.Empty(t, id.String())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewID(t *testing.T) {
|
||||||
|
t.Run("default values", func(t *testing.T) {
|
||||||
|
id := NewID()
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
idV2 := id.ToV2()
|
||||||
|
|
||||||
|
require.Nil(t, idV2.GetValue())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue