forked from TrueCloudLab/frostfs-s3-gw
[#180] api: Add unittests
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
88aaad361a
commit
eaec271283
1 changed files with 37 additions and 0 deletions
37
api/handler/object_list_test.go
Normal file
37
api/handler/object_list_test.go
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestParseContinuationToken(t *testing.T) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
t.Run("empty token", func(t *testing.T) {
|
||||||
|
var queryValues = map[string][]string{
|
||||||
|
"continuation-token": {""},
|
||||||
|
}
|
||||||
|
_, err = parseContinuationToken(queryValues)
|
||||||
|
require.Error(t, err)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("invalid not empty token", func(t *testing.T) {
|
||||||
|
var queryValues = map[string][]string{
|
||||||
|
"continuation-token": {"asd"},
|
||||||
|
}
|
||||||
|
_, err = parseContinuationToken(queryValues)
|
||||||
|
require.Error(t, err)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("valid token", func(t *testing.T) {
|
||||||
|
tokenStr := "75BTT5Z9o79XuKdUeGqvQbqDnxu6qWcR5EhxW8BXFf8t"
|
||||||
|
var queryValues = map[string][]string{
|
||||||
|
"continuation-token": {tokenStr},
|
||||||
|
}
|
||||||
|
token, err := parseContinuationToken(queryValues)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, tokenStr, token)
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in a new issue