Skip to content

Commit 8e480e3

Browse files
author
Brian Chen
authored
Run IN query integration tests only when running against emulator (#567)
1 parent add8c9b commit 8e480e3

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryTest.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.firebase.firestore;
1616

17+
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.isRunningAgainstEmulator;
1718
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.querySnapshotToIds;
1819
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.querySnapshotToValues;
1920
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
@@ -38,7 +39,7 @@
3839
import java.util.Map;
3940
import java.util.concurrent.Semaphore;
4041
import org.junit.After;
41-
import org.junit.Ignore;
42+
import org.junit.Assume;
4243
import org.junit.Test;
4344
import org.junit.runner.RunWith;
4445

@@ -428,33 +429,33 @@ public void testQueriesCanUseArrayContainsFilters() {
428429
// much of anything else interesting to test.
429430
}
430431

431-
// TODO(in-queries): Re-enable once emulator support is added to travis.
432+
// TODO(in-queries): Re-enable in prod once feature lands in backend.
432433
@Test
433-
@Ignore
434434
public void testQueriesCanUseInFilters() {
435-
Map<String, Object> docA = map("zip", 98101);
436-
Map<String, Object> docB = map("zip", 91102);
437-
Map<String, Object> docC = map("zip", 98103);
438-
Map<String, Object> docD = map("zip", asList(98101));
439-
Map<String, Object> docE = map("zip", asList("98101", map("zip", 98101)));
440-
Map<String, Object> docF = map("zip", map("code", 500));
435+
Assume.assumeTrue(isRunningAgainstEmulator());
436+
Map<String, Object> docA = map("zip", 98101L);
437+
Map<String, Object> docB = map("zip", 91102L);
438+
Map<String, Object> docC = map("zip", 98103L);
439+
Map<String, Object> docD = map("zip", asList(98101L));
440+
Map<String, Object> docE = map("zip", asList("98101", map("zip", 98101L)));
441+
Map<String, Object> docF = map("zip", map("code", 500L));
441442
CollectionReference collection =
442443
testCollectionWithDocs(
443444
map("a", docA, "b", docB, "c", docC, "d", docD, "e", docE, "f", docF));
444445

445446
// Search for zips matching [98101, 98103].
446-
QuerySnapshot snapshot = waitFor(collection.whereIn("zip", asList(98101, 98103)).get());
447+
QuerySnapshot snapshot = waitFor(collection.whereIn("zip", asList(98101L, 98103L)).get());
447448
assertEquals(asList(docA, docC), querySnapshotToValues(snapshot));
448449

449450
// With objects.
450-
snapshot = waitFor(collection.whereIn("zip", asList(map("code", 500))).get());
451+
snapshot = waitFor(collection.whereIn("zip", asList(map("code", 500L))).get());
451452
assertEquals(asList(docF), querySnapshotToValues(snapshot));
452453
}
453454

454-
// TODO(in-queries): Re-enable once emulator support is added to travis.
455+
// TODO(in-queries): Re-enable in prod once feature lands in backend.
455456
@Test
456-
@Ignore
457457
public void testQueriesCanUseArrayContainsAnyFilters() {
458+
Assume.assumeTrue(isRunningAgainstEmulator());
458459
Map<String, Object> docA = map("array", asList(42L));
459460
Map<String, Object> docB = map("array", asList("a", 42L, "c"));
460461
Map<String, Object> docC = map("array", asList(41.999, "42", map("a", asList(42))));

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,4 +422,8 @@ public static Map<String, Object> toDataMap(QuerySnapshot qrySnap) {
422422
}
423423
return result;
424424
}
425+
426+
public static boolean isRunningAgainstEmulator() {
427+
return CONNECT_TO_EMULATOR;
428+
}
425429
}

0 commit comments

Comments
 (0)