Skip to content

Commit

Permalink
Make events parameter required for ListEvents (#325)
Browse files Browse the repository at this point in the history
* Make events parameter required for ListEvents.

* Fix formatting.

* Bump minor version.

* Undo version bump.
  • Loading branch information
mattgd authored Apr 11, 2024
1 parent d06b649 commit 87de1f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/events/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type Event struct {
// ListEventsOpts contains the options to request provisioned Events.
type ListEventsOpts struct {
// Filter to only return Events of particular types.
Events []string `url:"events,omitempty"`
Events []string `url:"events"`

// Maximum number of records to return.
Limit int `url:"limit"`
Expand Down
6 changes: 5 additions & 1 deletion pkg/events/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ func TestListEvents(t *testing.T) {
},
}

events, err := client.ListEvents(context.Background(), ListEventsOpts{})
params := ListEventsOpts{
Events: []string{"dsync.user.created"},
}
events, err := client.ListEvents(context.Background(), params)

require.NoError(t, err)
require.Equal(t, expectedResponse, events)
Expand All @@ -56,6 +59,7 @@ func TestListEvents(t *testing.T) {
rangeEnd := currentTime.AddDate(0, 0, -1)

params := ListEventsOpts{
Events: []string{"dsync.user.created"},
RangeStart: rangeStart.String(),
RangeEnd: rangeEnd.String(),
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/events/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func TestEventsListEvents(t *testing.T) {
}
SetAPIKey("test")

params := ListEventsOpts{
Events: []string{"dsync.user.created"},
}

expectedResponse := ListEventsResponse{
Data: []Event{
{
Expand All @@ -33,7 +37,7 @@ func TestEventsListEvents(t *testing.T) {
After: "",
},
}
eventsResponse, err := ListEvents(context.Background(), ListEventsOpts{})
eventsResponse, err := ListEvents(context.Background(), params)

require.NoError(t, err)
require.Equal(t, expectedResponse, eventsResponse)
Expand Down

0 comments on commit 87de1f7

Please sign in to comment.