Skip to content

Commit

Permalink
Add tests for pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
alandotcom authored and bitfield committed Aug 15, 2019
1 parent 7711ffd commit 246b3dd
Show file tree
Hide file tree
Showing 4 changed files with 2,473 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (c *Client) GetMonitor(ID int64) (Monitor, error) {
return r.Monitors[0], nil
}

// PageLimit is the default limit for monitors returned per page.
const PageLimit = 50

// AllMonitors returns a slice of Monitors representing the monitors currently
Expand Down Expand Up @@ -129,7 +130,8 @@ func (c *Client) AllMonitors() (monitors []Monitor, err error) {

offset = r.Pagination.Offset + limit
total := r.Pagination.Total
loopCondition = (offset+limit < total)

loopCondition = offset < total
}

return monitors, err
Expand Down
Loading

0 comments on commit 246b3dd

Please sign in to comment.