Delete unused function

This commit is contained in:
Luis Eduardo Jeréz Girón
2024-07-21 18:55:29 -06:00
parent 96c91faa77
commit 4d050c0a89
2 changed files with 0 additions and 74 deletions

View File

@@ -1,14 +0,0 @@
package paginateutil
// HasNextPage returns true if there are more pages to show.
func HasNextPage(
totalItems int,
limit int,
offset int,
) bool {
if totalItems <= 0 {
return false
}
return totalItems > offset+limit
}

View File

@@ -1,60 +0,0 @@
package paginateutil
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestHasNextPage(t *testing.T) {
tests := []struct {
name string
totalItems int
limit int
offset int
want bool
}{
{
name: "No items",
totalItems: 0,
limit: 10,
offset: 0,
want: false,
},
{
name: "Exact number of items as limit",
totalItems: 10,
limit: 10,
offset: 0,
want: false,
},
{
name: "More items than limit",
totalItems: 15,
limit: 10,
offset: 0,
want: true,
},
{
name: "No more items beyond current page",
totalItems: 20,
limit: 10,
offset: 10,
want: false,
},
{
name: "More items beyond current page",
totalItems: 25,
limit: 10,
offset: 10,
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := HasNextPage(tt.totalItems, tt.limit, tt.offset)
assert.Equal(t, tt.want, got)
})
}
}