forked from TrueCloudLab/frostfs-api-go
[#168] container: Implement binary/JSON encoders/decoders on Container
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
bc5d9dcce5
commit
a684da6118
6 changed files with 97 additions and 50 deletions
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue