Skip to content

Commit

Permalink
Updating Watch conformance tests (#3202)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored and pongad committed Apr 27, 2018
1 parent 0097ffa commit 4108659
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ public synchronized void onNext(ListenResponse listenResponse) {
}
break;
case ADD:
Preconditions.checkState(
WATCH_TARGET_ID == change.getTargetIds(0), "Target ID must be 0xD0");
if (WATCH_TARGET_ID != change.getTargetIds(0)) {
closeStream(FirestoreException.invalidState("Target ID must be 0x01"));
}
break;
case REMOVE:
Status status =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ private void runQueryTest(TestDefinition.QueryTest testCase) {
}
}

private void runWatchTest(TestDefinition.ListenTest testCase)
private void runWatchTest(final TestDefinition.ListenTest testCase)
throws ExecutionException, InterruptedException {
final SettableApiFuture<Void> testCaseStarted = SettableApiFuture.create();
final SettableApiFuture<Void> testCaseFinished = SettableApiFuture.create();
Expand All @@ -464,10 +464,20 @@ public ApiStreamObserver<ListenRequest> answer(InvocationOnMock invocationOnMock
public void onEvent(
@Nullable QuerySnapshot actualSnapshot, @Nullable FirestoreException error) {
try {
Assert.assertFalse(expectedSnapshots.isEmpty());
Snapshot expectedSnapshot = expectedSnapshots.remove(0);
Assert.assertEquals(convertQuerySnapshot(expectedSnapshot), actualSnapshot);
if (expectedSnapshots.isEmpty()) {
if (actualSnapshot != null) {
Assert.assertNull(error);
Assert.assertFalse(expectedSnapshots.isEmpty());
Snapshot expectedSnapshot = expectedSnapshots.remove(0);
Assert.assertEquals(convertQuerySnapshot(expectedSnapshot), actualSnapshot);
if (expectedSnapshots.isEmpty()) {
if (!testCase.getIsError()) {
testCaseFinished.set(null);
}
}
} else { // Error case
Assert.assertNotNull(error);
Assert.assertTrue(expectedSnapshots.isEmpty());
Assert.assertTrue(testCase.getIsError());
testCaseFinished.set(null);
}
} catch (AssertionError e) {
Expand Down
Binary file modified google-cloud-firestore/src/test/resources/test-suite.binproto
Binary file not shown.

0 comments on commit 4108659

Please sign in to comment.