2021-10-27 07:41:05 +00:00
|
|
|
package version
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-10-07 14:20:25 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
|
2021-10-27 07:41:05 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewVersion(t *testing.T) {
|
|
|
|
t.Run("default values", func(t *testing.T) {
|
2022-03-23 15:35:44 +00:00
|
|
|
var v Version
|
2021-10-27 07:41:05 +00:00
|
|
|
|
|
|
|
// check initial values
|
|
|
|
require.Zero(t, v.Major())
|
|
|
|
require.Zero(t, v.Minor())
|
|
|
|
|
|
|
|
// convert to v2 message
|
2022-03-23 15:35:44 +00:00
|
|
|
var vV2 refs.Version
|
|
|
|
v.WriteToV2(&vV2)
|
2021-10-27 07:41:05 +00:00
|
|
|
|
2022-03-23 15:35:44 +00:00
|
|
|
require.Zero(t, vV2.GetMajor())
|
|
|
|
require.Zero(t, vV2.GetMinor())
|
2021-10-27 07:41:05 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("setting values", func(t *testing.T) {
|
2022-03-23 15:35:44 +00:00
|
|
|
var v Version
|
2021-10-27 07:41:05 +00:00
|
|
|
|
|
|
|
var mjr, mnr uint32 = 1, 2
|
|
|
|
|
|
|
|
v.SetMajor(mjr)
|
|
|
|
v.SetMinor(mnr)
|
|
|
|
require.Equal(t, mjr, v.Major())
|
|
|
|
require.Equal(t, mnr, v.Minor())
|
|
|
|
|
2022-03-23 15:35:44 +00:00
|
|
|
// convert to v2 message
|
|
|
|
var ver refs.Version
|
|
|
|
v.WriteToV2(&ver)
|
2021-10-27 07:41:05 +00:00
|
|
|
|
|
|
|
require.Equal(t, mjr, ver.GetMajor())
|
|
|
|
require.Equal(t, mnr, ver.GetMinor())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSDKVersion(t *testing.T) {
|
|
|
|
v := Current()
|
|
|
|
|
|
|
|
require.Equal(t, uint32(sdkMjr), v.Major())
|
|
|
|
require.Equal(t, uint32(sdkMnr), v.Minor())
|
|
|
|
}
|