forked from TrueCloudLab/frostfs-api-go
[#309] pkg/session: Add marshal-unmarshal
Added Marshal, Unmarshal, MarshalJSON, UnmarshalJSON methods to ContainerContext Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
86d446f54c
commit
8ea9993577
2 changed files with 49 additions and 0 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||
sessiontest "github.com/nspcc-dev/neofs-api-go/pkg/session/test"
|
||||
v2session "github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -85,3 +86,27 @@ func TestFilter_ToV2(t *testing.T) {
|
|||
require.Nil(t, cV2.ContainerID())
|
||||
})
|
||||
}
|
||||
|
||||
func TestContainerContextEncoding(t *testing.T) {
|
||||
c := sessiontest.ContainerContext()
|
||||
|
||||
t.Run("binary", func(t *testing.T) {
|
||||
data, err := c.Marshal()
|
||||
require.NoError(t, err)
|
||||
|
||||
c2 := session.NewContainerContext()
|
||||
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 := session.NewContainerContext()
|
||||
require.NoError(t, c2.UnmarshalJSON(data))
|
||||
|
||||
require.Equal(t, c, c2)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue