frostfs-api-go/session/store_test.go
Leonard Lyubich 22265a9f03 session: refactor token store
This commit:

  * changes the set and signatures of TokenStore interface methods;

  * adds unit test for map storage.
2020-04-29 12:39:41 +03:00

35 lines
760 B
Go

package session
import (
"testing"
"github.com/nspcc-dev/neofs-api-go/refs"
"github.com/stretchr/testify/require"
)
func TestMapTokenStore(t *testing.T) {
// create new private token
pToken, err := NewPrivateToken()
require.NoError(t, err)
// create map token store
s := NewMapTokenStore()
// create new storage key
id, err := refs.NewUUID()
require.NoError(t, err)
// ascertain that there is no record for the key
_, err = s.Fetch(id)
require.EqualError(t, err, ErrPrivateTokenNotFound.Error())
// save private token record
require.NoError(t, s.Store(id, pToken))
// fetch private token by the key
res, err := s.Fetch(id)
require.NoError(t, err)
// ascertain that returned token equals to initial
require.Equal(t, pToken, res)
}