Skip to content

Commit

Permalink
Merge pull request drone#84 from bigkevmcd/fix-pagination
Browse files Browse the repository at this point in the history
fix: If we have no default page or other options, respond with all items.
  • Loading branch information
jenkins-x-bot authored Mar 19, 2020
2 parents 1b5d9ac + 926dbe5 commit 9468dc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions scm/driver/fake/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func TestPaginated(t *testing.T) {
{2, 5, 10, 5, 10},
{2, 5, 9, 5, 9},
{4, 5, 10, 10, 10}, // this results in an empty slice
{0, 0, 10, 0, 10}, // this is the default 0 value for ListOption
}

for _, tt := range tests {
Expand Down
7 changes: 7 additions & 0 deletions scm/driver/fake/utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package fake

func paginated(page, size, items int) (start, end int) {
// handle the default value case for ListOptions.
if page == 0 && size == 0 {
start = 0
end = items
return
}

start = (page - 1) * size
if start > items {
start = items
Expand Down

0 comments on commit 9468dc4

Please sign in to comment.