Skip to content

Commit

Permalink
allow cursor with query
Browse files Browse the repository at this point in the history
  • Loading branch information
cynicaljoy committed Nov 7, 2024
1 parent 64ad86c commit b52bd80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
19 changes: 9 additions & 10 deletions Fauna.Test/Integration.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -661,28 +661,27 @@ await _client.QueryAsync(
}

[Test, Category("EventFeed")]
public void ThrowsWhenQueryDoesntReturnEventSource()
public async Task CanUseCursorWithQuery()
{
var ex = Assert.ThrowsAsync<InvalidOperationException>(async () =>
await _client.EventFeedAsync<StreamingSandbox>(FQL($"42"))
var feed = await _client.EventFeedAsync<StreamingSandbox>(
FQL($"StreamingSandbox.all().eventSource()"),
feedOptions: new FeedOptions("abc1234==")
);

Assert.That(ex!.Message, Does.Contain("Query must return an EventSource."));
Assert.NotNull(feed);
}

[Test, Category("EventFeed")]
public void ThrowsWhenAttemptingToUseCursorWithQuery()
public void ThrowsWhenQueryDoesntReturnEventSource()
{
var ex = Assert.ThrowsAsync<InvalidOperationException>(async () =>
await _client.EventFeedAsync<StreamingSandbox>(
FQL($"StreamingSandbox.all().eventSource()"),
feedOptions: new FeedOptions("abc1234==")
)
await _client.EventFeedAsync<StreamingSandbox>(FQL($"42"))
);

Assert.AreEqual("Cannot use Cursor when opening an EventFeed with a Query.", ex!.Message);
Assert.That(ex!.Message, Does.Contain("Query must return an EventSource."));
}


#endregion

[Test]
Expand Down
5 changes: 0 additions & 5 deletions Fauna/IClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,6 @@ public async Task<FeedEnumerable<T>> EventFeedAsync<T>(
FeedOptions? feedOptions = null,
CancellationToken cancellationToken = default) where T : notnull
{
if (feedOptions?.Cursor != null)
{
throw new InvalidOperationException("Cannot use Cursor when opening an EventFeed with a Query.");
}

EventSource eventSource = await GetEventSourceFromQueryAsync(query, null, cancellationToken);
if (feedOptions != null) eventSource.Options = feedOptions;

Expand Down

0 comments on commit b52bd80

Please sign in to comment.