Skip to content

Run IN query integration tests only when running against emulator #567

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

Merged
merged 5 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.firebase.firestore;

import static com.google.firebase.firestore.testutil.IntegrationTestUtil.isRunningAgainstEmulator;
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.querySnapshotToIds;
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.querySnapshotToValues;
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
Expand All @@ -38,7 +39,6 @@
import java.util.Map;
import java.util.concurrent.Semaphore;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand Down Expand Up @@ -428,33 +428,37 @@ public void testQueriesCanUseArrayContainsFilters() {
// much of anything else interesting to test.
}

// TODO(in-queries): Re-enable once emulator support is added to travis.
// TODO(in-queries): Re-enable in prod once feature lands in backend.
@Test
@Ignore
public void testQueriesCanUseInFilters() {
Map<String, Object> docA = map("zip", 98101);
Map<String, Object> docB = map("zip", 91102);
Map<String, Object> docC = map("zip", 98103);
Map<String, Object> docD = map("zip", asList(98101));
Map<String, Object> docE = map("zip", asList("98101", map("zip", 98101)));
Map<String, Object> docF = map("zip", map("code", 500));
if (!isRunningAgainstEmulator()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you looked into this - but what is your reason for not using assumeTrue()?

https://reflectoring.io/conditional-junit4-junit5-tests/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I had was that assumeTrue() wasn't used anywhere else in the codebase, but I guess that's not a valid reason to avoid using it.

return;
}
Map<String, Object> docA = map("zip", 98101L);
Map<String, Object> docB = map("zip", 91102L);
Map<String, Object> docC = map("zip", 98103L);
Map<String, Object> docD = map("zip", asList(98101L));
Map<String, Object> docE = map("zip", asList("98101", map("zip", 98101L)));
Map<String, Object> docF = map("zip", map("code", 500L));
CollectionReference collection =
testCollectionWithDocs(
map("a", docA, "b", docB, "c", docC, "d", docD, "e", docE, "f", docF));

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

// With objects.
snapshot = waitFor(collection.whereIn("zip", asList(map("code", 500))).get());
snapshot = waitFor(collection.whereIn("zip", asList(map("code", 500L))).get());
assertEquals(asList(docF), querySnapshotToValues(snapshot));
}

// TODO(in-queries): Re-enable once emulator support is added to travis.
// TODO(in-queries): Re-enable in prod once feature lands in backend.
@Test
@Ignore
public void testQueriesCanUseArrayContainsAnyFilters() {
if (!isRunningAgainstEmulator()) {
return;
}
Map<String, Object> docA = map("array", asList(42L));
Map<String, Object> docB = map("array", asList("a", 42L, "c"));
Map<String, Object> docC = map("array", asList(41.999, "42", map("a", asList(42))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,8 @@ public static Map<String, Object> toDataMap(QuerySnapshot qrySnap) {
}
return result;
}

public static boolean isRunningAgainstEmulator() {
return CONNECT_TO_EMULATOR;
}
}