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
parent
01596453bd
commit
81f9e410f9
|
@ -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{}
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue