package apemanager_test import ( "testing" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apemanager" "github.com/stretchr/testify/require" apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" ) var ( m = map[apemanager.TargetType]apemanager_v2.TargetType{ apemanager.TargetTypeUndefined: apemanager_v2.TargetTypeUndefined, apemanager.TargetTypeNamespace: apemanager_v2.TargetTypeNamespace, apemanager.TargetTypeContainer: apemanager_v2.TargetTypeContainer, apemanager.TargetTypeUser: apemanager_v2.TargetTypeUser, apemanager.TargetTypeGroup: apemanager_v2.TargetTypeGroup, } ) func TestTargetType(t *testing.T) { for typesdk, typev2 := range m { t.Run("from sdk to v2 "+typev2.String(), func(t *testing.T) { v2 := typesdk.ToV2() require.Equal(t, v2, typev2) }) t.Run("from v2 to sdk "+typev2.String(), func(t *testing.T) { var typ apemanager.TargetType typ.FromV2(typev2) require.Equal(t, typesdk, typ) }) } } func TestChainTarget(t *testing.T) { var ( typ = apemanager.TargetTypeNamespace name = "namespaceXXYYZZ" ) t.Run("from sdk to v2", func(t *testing.T) { ct := apemanager.ChainTarget{ TargetType: typ, Name: name, } v2 := ct.ToV2() require.Equal(t, m[typ], v2.GetTargetType()) require.Equal(t, name, v2.GetName()) }) t.Run("from v2 to sdk", func(t *testing.T) { v2 := &apemanager_v2.ChainTarget{} v2.SetTargetType(m[typ]) v2.SetName(name) var ct apemanager.ChainTarget ct.FromV2(v2) require.Equal(t, typ, ct.TargetType) require.Equal(t, name, ct.Name) }) }