Skip to content

Commit

Permalink
fix(pagination): Fix pagination for datadog_incidents table (#11230)
Browse files Browse the repository at this point in the history
Follow-up for #11229
  • Loading branch information
candiduslynx committed Jun 6, 2023
1 parent e2a07a2 commit b0eae04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions plugins/source/datadog/resources/services/incidents/incidents.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ func Incidents() *schema.Table {
}
}

func fetchIncidents(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
func fetchIncidents(ctx context.Context, meta schema.ClientMeta, _ *schema.Resource, res chan<- any) error {
c := meta.(*client.Client)
ctx = c.BuildContextV2(ctx)
resp, _, err := c.DDServices.IncidentsAPI.ListIncidents(ctx)
if err != nil {
return err
}
res <- resp.GetData()
return nil
resp, cancel := c.DDServices.IncidentsAPI.ListIncidentsWithPagination(ctx)
return client.ConsumePaginatedResponse(resp, cancel, res)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ func buildIncidentsMock(t *testing.T, ctrl *gomock.Controller) client.DatadogSer
IncidentsAPI: m,
}

var i datadogV2.IncidentsResponse
var i datadogV2.IncidentResponseData
err := faker.FakeObject(&i)
if err != nil {
t.Fatal(err)
}
m.EXPECT().ListIncidents(gomock.Any()).Return(i, nil, nil)
m.EXPECT().ListIncidentsWithPagination(gomock.Any()).Return(client.MockPaginatedResponse(i))

var ar datadogV2.IncidentAttachmentsResponse
err = faker.FakeObject(&ar)
Expand Down

0 comments on commit b0eae04

Please sign in to comment.