2021-11-23 18:20:12 +00:00
|
|
|
package subnet_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-03-07 11:20:03 +00:00
|
|
|
. "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/subnet"
|
|
|
|
subnetid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/subnet/id"
|
|
|
|
subnetidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/subnet/id/test"
|
|
|
|
subnettest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/subnet/test"
|
|
|
|
usertest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user/test"
|
2021-11-23 18:20:12 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestInfoZero(t *testing.T) {
|
2021-11-26 11:03:27 +00:00
|
|
|
var info Info
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
require.Zero(t, info.ID())
|
|
|
|
require.True(t, subnetid.IsZero(info.ID()))
|
2021-11-23 18:20:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestInfo_SetID(t *testing.T) {
|
2022-06-15 07:12:35 +00:00
|
|
|
id := subnetidtest.ID()
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
var info Info
|
2021-11-26 11:03:27 +00:00
|
|
|
info.SetID(id)
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
require.Equal(t, id, info.ID())
|
|
|
|
require.True(t, AssertReference(info, id))
|
2021-11-23 18:20:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestInfo_SetOwner(t *testing.T) {
|
2022-06-15 07:12:35 +00:00
|
|
|
id := *usertest.ID()
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
var info Info
|
2021-11-26 11:03:27 +00:00
|
|
|
info.SetOwner(id)
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
require.Equal(t, id, info.Owner())
|
|
|
|
require.True(t, AssertOwnership(info, id))
|
2021-11-23 18:20:12 +00:00
|
|
|
}
|
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
func TestInfo_Marshal(t *testing.T) {
|
|
|
|
info := subnettest.Info()
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
var info2 Info
|
|
|
|
require.NoError(t, info2.Unmarshal(info.Marshal()))
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
require.Equal(t, info, info2)
|
2021-11-23 18:20:12 +00:00
|
|
|
}
|