Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow Cursor with Event Feeds from Query #181

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,6 @@ func (c *Client) FeedFromQuery(query *Query, opts ...FeedOptFn) (*EventFeed, err
if err != nil {
return nil, err
}
if feedOpts.Cursor != nil {
return nil, fmt.Errorf("cannot use EventFeedCursor with FeedFromQuery")
}

res, err := c.Query(query)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions event_feed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ func TestEventFeed(t *testing.T) {
require.ErrorContains(t, feedErr, "query should return a fauna.EventSource but got int")
})

t.Run("should error when attempting to use a cursor with a query", func(t *testing.T) {
t.Run("should allow passing a cursor with a query", func(t *testing.T) {
query, queryErr := fauna.FQL(`EventFeedTest.all().eventSource()`, nil)
require.NoError(t, queryErr, "failed to create a query for EventSource")

_, feedErr := client.FeedFromQuery(query, fauna.EventFeedCursor("cursor"))
require.ErrorContains(t, feedErr, "cannot use EventFeedCursor with FeedFromQuery")
feed, feedErr := client.FeedFromQuery(query, fauna.EventFeedCursor("cursor"))
require.NoError(t, feedErr, "failed to init events feed")
require.NotNil(t, feed, "feed is nil")
})

t.Run("should error when attempting to use a start time and a cursor", func(t *testing.T) {
Expand Down
Loading