forked from TrueCloudLab/frostfs-api-go
[#302] pkg/version: Document default values set in NewVersion
Document field values of instance constructed via `NewVersion`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
768adfdd15
commit
dc99d4edce
2 changed files with 29 additions and 9 deletions
|
@ -21,6 +21,10 @@ func NewVersionFromV2(v *refs.Version) *Version {
|
||||||
// NewVersion creates and initializes blank Version.
|
// NewVersion creates and initializes blank Version.
|
||||||
//
|
//
|
||||||
// Works similar as NewVersionFromV2(new(Version)).
|
// Works similar as NewVersionFromV2(new(Version)).
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - major: 0;
|
||||||
|
// - minor: 0.
|
||||||
func NewVersion() *Version {
|
func NewVersion() *Version {
|
||||||
return NewVersionFromV2(new(refs.Version))
|
return NewVersionFromV2(new(refs.Version))
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,21 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewVersion(t *testing.T) {
|
func TestNewVersion(t *testing.T) {
|
||||||
|
t.Run("default values", func(t *testing.T) {
|
||||||
|
v := NewVersion()
|
||||||
|
|
||||||
|
// check initial values
|
||||||
|
require.Zero(t, v.Major())
|
||||||
|
require.Zero(t, v.Minor())
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
vV2 := v.ToV2()
|
||||||
|
|
||||||
|
require.Empty(t, vV2.GetMajor())
|
||||||
|
require.Empty(t, vV2.GetMinor())
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("setting values", func(t *testing.T) {
|
||||||
v := NewVersion()
|
v := NewVersion()
|
||||||
|
|
||||||
var mjr, mnr uint32 = 1, 2
|
var mjr, mnr uint32 = 1, 2
|
||||||
|
@ -22,6 +37,7 @@ func TestNewVersion(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, mjr, ver.GetMajor())
|
require.Equal(t, mjr, ver.GetMajor())
|
||||||
require.Equal(t, mnr, ver.GetMinor())
|
require.Equal(t, mnr, ver.GetMinor())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSDKVersion(t *testing.T) {
|
func TestSDKVersion(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue