forked from TrueCloudLab/frostfs-sdk-go
[#227] netmap: Add more encoding methods for PlacementPolicy
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
e999fb00c3
commit
e986f47807
2 changed files with 66 additions and 2 deletions
|
@ -1,9 +1,11 @@
|
|||
package netmap
|
||||
package netmap_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
. "github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
netmaptest "github.com/nspcc-dev/neofs-sdk-go/netmap/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -34,3 +36,24 @@ FILTER City EQ SPB AND SSD EQ true OR City EQ SPB AND Rating GE 5 AS SPBSSD`,
|
|||
require.Equal(t, testCase, b.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlacementPolicyEncoding(t *testing.T) {
|
||||
v := netmaptest.PlacementPolicy()
|
||||
|
||||
t.Run("binary", func(t *testing.T) {
|
||||
var v2 PlacementPolicy
|
||||
require.NoError(t, v2.Unmarshal(v.Marshal()))
|
||||
|
||||
require.Equal(t, v, v2)
|
||||
})
|
||||
|
||||
t.Run("json", func(t *testing.T) {
|
||||
data, err := v.MarshalJSON()
|
||||
require.NoError(t, err)
|
||||
|
||||
var v2 PlacementPolicy
|
||||
require.NoError(t, v2.UnmarshalJSON(data))
|
||||
|
||||
require.Equal(t, v, v2)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue