forked from TrueCloudLab/frostfs-api-go
[#302] pkg/object: Document default values set in NewSplitInfo
Document field values of instance constructed via `NewSplitInfo`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
5cbdef1e46
commit
dde721ea9f
2 changed files with 24 additions and 0 deletions
|
@ -13,6 +13,12 @@ func NewSplitInfoFromV2(v2 *object.SplitInfo) *SplitInfo {
|
||||||
return (*SplitInfo)(v2)
|
return (*SplitInfo)(v2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewSplitInfo creates and initializes blank SplitInfo.
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - splitID: nil;
|
||||||
|
// - lastPart nil;
|
||||||
|
// - link: nil.
|
||||||
func NewSplitInfo() *SplitInfo {
|
func NewSplitInfo() *SplitInfo {
|
||||||
return NewSplitInfoFromV2(new(object.SplitInfo))
|
return NewSplitInfoFromV2(new(object.SplitInfo))
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,3 +68,21 @@ func TestSplitInfo_ToV2(t *testing.T) {
|
||||||
require.Nil(t, x.ToV2())
|
require.Nil(t, x.ToV2())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewSplitInfo(t *testing.T) {
|
||||||
|
t.Run("default values", func(t *testing.T) {
|
||||||
|
si := object.NewSplitInfo()
|
||||||
|
|
||||||
|
// check initial values
|
||||||
|
require.Nil(t, si.SplitID())
|
||||||
|
require.Nil(t, si.LastPart())
|
||||||
|
require.Nil(t, si.Link())
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
siV2 := si.ToV2()
|
||||||
|
|
||||||
|
require.Nil(t, siV2.GetSplitID())
|
||||||
|
require.Nil(t, siV2.GetLastPart())
|
||||||
|
require.Nil(t, siV2.GetLink())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue