Skip to content

Commit

Permalink
Don't raise empty Snapshots on resets (googleapis#3750)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored Oct 4, 2018
1 parent 63aff86 commit 0f3bc0e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ public void run() {
Preconditions.checkState(stream == null);

current = false;
hasPushed = false;
nextAttempt = backoff.createNextAttempt(nextAttempt);

stream = firestore.streamRequest(Watch.this, firestore.getClient().listenCallable());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,35 @@ public void queryWatchReopensOnUnexceptedStreamEnd() throws InterruptedException
awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc", SINGLE_FIELD_MAP));
}

@Test
public void queryWatchDoesntSendRaiseSnapshotOnReset() throws InterruptedException {
// This test is meant to reproduce https://github.com/googleapis/google-cloud-dotnet/issues/2542
addQueryListener();

awaitAddTarget();

send(addTarget());
send(current());
send(snapshot());

awaitQuerySnapshot();

close();
awaitClose();
awaitAddTarget();

send(addTarget());
send(current());
// This should not raise a snapshot, since nothing has changed since the last snapshot.
send(snapshot());

send(doc("coll/doc", SINGLE_FIELD_PROTO));
send(snapshot());

// Verify that we only receveived one snapshot.
awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc", SINGLE_FIELD_MAP));
}

@Test
public void queryWatchDoesntReopenInactiveStream() throws InterruptedException {
addQueryListener();
Expand Down

0 comments on commit 0f3bc0e

Please sign in to comment.