From cf49872ce6b7fd0c687ee8e09496cdd74a77d515 Mon Sep 17 00:00:00 2001 From: SimoneDutto Date: Wed, 4 Sep 2024 13:02:31 +0200 Subject: [PATCH] add test for pagination function --- internal/common/pagination/pagination_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/common/pagination/pagination_test.go b/internal/common/pagination/pagination_test.go index 18c3769cf..518605215 100644 --- a/internal/common/pagination/pagination_test.go +++ b/internal/common/pagination/pagination_test.go @@ -130,6 +130,18 @@ func TestCreatePagination(t *testing.T) { } } +// test the requested size is 1 more than then page size. +func TestCreatePaginationWithoutTotal(t *testing.T) { + c := qt.New(t) + pPage := utils.IntToPointer(0) + pSize := utils.IntToPointer(10) + page, size, pag := pagination.CreatePaginationWithoutTotal(pSize, pPage) + c.Assert(page, qt.Equals, 0) + c.Assert(pag.Limit(), qt.Equals, 11) + c.Assert(pag.Offset(), qt.Equals, 0) + c.Assert(size, qt.Equals, 11) +} + func TestTokenFilter(t *testing.T) { testToken := "test-token" testCases := []struct {