[#168] container: Implement binary/JSON encoders/decoders on Container

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-13 15:21:34 +03:00 committed by Alex Vanin
parent bc5d9dcce5
commit a684da6118
6 changed files with 97 additions and 50 deletions

View file

@ -66,3 +66,29 @@ func generatePlacementPolicy() *netmap.PlacementPolicy {
return p
}
func TestContainerEncoding(t *testing.T) {
c := container.New(
container.WithAttribute("key", "value"),
)
t.Run("binary", func(t *testing.T) {
data, err := c.Marshal()
require.NoError(t, err)
c2 := container.New()
require.NoError(t, c2.Unmarshal(data))
require.Equal(t, c, c2)
})
t.Run("json", func(t *testing.T) {
data, err := c.MarshalJSON()
require.NoError(t, err)
c2 := container.New()
require.NoError(t, c2.UnmarshalJSON(data))
require.Equal(t, c, c2)
})
}