Fix issue where offset & limit won't work

Because we were testing the mock client, and not the paginating
kapacitor client for the case where limit and offset were provided, an
issue with that code path was not exposed.

The issues exposed were that the condition was incorrect for triggering
this behavior, and no return clause was present to prevent the remainder
of the ListTasks method from running.
pull/1886/head
Tim Raymond 2017-08-18 17:07:00 -04:00
parent 01596453bd
commit 81f9e410f9
2 changed files with 3 additions and 3 deletions

View File

@ -18,8 +18,8 @@ type PaginatingKapaClient struct {
// it fetches them
func (p *PaginatingKapaClient) ListTasks(opts *client.ListTasksOptions) ([]client.Task, error) {
// only trigger auto-pagination with Offset=0 and Limit=0
if opts.Limit != 0 && opts.Offset != 0 {
p.KapaClient.ListTasks(opts)
if opts.Limit != 0 || opts.Offset != 0 {
return p.KapaClient.ListTasks(opts)
}
allTasks := []client.Task{}

View File

@ -38,7 +38,7 @@ func Test_Kapacitor_PaginatingKapaClient(t *testing.T) {
}
// ensure 100 elems returned when calling mockClient directly
tasks, _ := mockClient.ListTasks(opts)
tasks, _ := pkap.ListTasks(opts)
if len(tasks) != 100 {
t.Error("Expected calling KapaClient's ListTasks to return", opts.Limit, "items. Received:", len(tasks))