fix: prevent negative slice index when last exceeds items count

This commit is contained in:
2026-01-01 15:09:00 +01:00
parent 02405c5ce1
commit bead25aa6b
2 changed files with 14 additions and 0 deletions
+11
View File
@@ -116,6 +116,17 @@ func TestGetPage(t *testing.T) {
EndCursor: ptr("MQ=="),
},
},
{
name: "last exceeds items count",
args: args[string]{items: []string{"1", "2", "3"}, last: ptr(10), max: 10, fn: func(s string) string { return s }},
wantItems: []string{"1", "2", "3"},
wantPageInfo: PageInfo{
StartCursor: ptr("MQ=="),
HasNextPage: false,
HasPreviousPage: false,
EndCursor: ptr("Mw=="),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {