forked from TrueCloudLab/frostfs-api-go
[#302] pkg/session: Convert nil Token
to nil message
Document that `Token.ToV2` method return `nil` when called on `nil`. Document that `NewTokenFromV2` function return `nil` when called on `nil`. Write corresponding unit tests. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
2d7a658059
commit
707776976a
2 changed files with 21 additions and 0 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
ownertest "github.com/nspcc-dev/neofs-api-go/pkg/owner/test"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||
sessiontest "github.com/nspcc-dev/neofs-api-go/pkg/session/test"
|
||||
sessionv2 "github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -162,3 +163,19 @@ func TestToken_Iat(t *testing.T) {
|
|||
|
||||
require.EqualValues(t, iat, tok.Iat())
|
||||
}
|
||||
|
||||
func TestNewTokenFromV2(t *testing.T) {
|
||||
t.Run("from nil", func(t *testing.T) {
|
||||
var x *sessionv2.SessionToken
|
||||
|
||||
require.Nil(t, session.NewTokenFromV2(x))
|
||||
})
|
||||
}
|
||||
|
||||
func TestToken_ToV2(t *testing.T) {
|
||||
t.Run("nil", func(t *testing.T) {
|
||||
var x *session.Token
|
||||
|
||||
require.Nil(t, x.ToV2())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue