From eaec271283f90fa77f74952487432744be9ab7a5 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Tue, 3 Aug 2021 12:40:28 +0300 Subject: [PATCH] [#180] api: Add unittests Signed-off-by: Angira Kekteeva --- api/handler/object_list_test.go | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 api/handler/object_list_test.go diff --git a/api/handler/object_list_test.go b/api/handler/object_list_test.go new file mode 100644 index 00000000..7b6a2f8f --- /dev/null +++ b/api/handler/object_list_test.go @@ -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) + }) +}