frostfs-api-go/v2/session/json_test.go
Leonard Lyubich 20bf21e5e4 [#168] session: Implement binary/JSON encoders/decoders on TokenLifetime
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-11-13 18:07:26 +03:00

32 lines
622 B
Go

package session_test
import (
"testing"
"github.com/nspcc-dev/neofs-api-go/v2/session"
"github.com/stretchr/testify/require"
)
func TestChecksumJSON(t *testing.T) {
ctx := generateObjectCtx("id")
data, err := ctx.MarshalJSON()
require.NoError(t, err)
ctx2 := new(session.ObjectSessionContext)
require.NoError(t, ctx2.UnmarshalJSON(data))
require.Equal(t, ctx, ctx2)
}
func TestTokenLifetimeJSON(t *testing.T) {
l := generateLifetime(1, 2, 3)
data, err := l.MarshalJSON()
require.NoError(t, err)
l2 := new(session.TokenLifetime)
require.NoError(t, l2.UnmarshalJSON(data))
require.Equal(t, l, l2)
}