Skip to content

Commit 24fba9b

Browse files
authored
fix: Improve efficiency of online/offline composite index tests. (#6868)
1 parent 5aff679 commit 24fba9b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ public void assertOnlineAndOfflineResultsMatch(
125125
@NonNull CollectionReference collection,
126126
@NonNull Query query,
127127
@NonNull String... expectedDocs) {
128-
checkOnlineAndOfflineResultsMatch(collection, query, toHashedIds(expectedDocs));
128+
// `checkOnlineAndOfflineResultsMatch` first makes sure all documents needed for
129+
// `query` are in the cache. It does so making a `get` on the first argument.
130+
// Since *all* composite index tests use the same collection, this is very inefficient to do.
131+
// Therefore, we should only do so for tests where `TEST_ID_FIELD` matches the current test.
132+
checkOnlineAndOfflineResultsMatch(this.query(collection), query, toHashedIds(expectedDocs));
129133
}
130134

131135
// Asserts that the IDs in the query snapshot matches the expected Ids. The expected document

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ public static List<Object> nullList() {
535535
* @param expectedDocs Ordered list of document keys that are expected to match the query
536536
*/
537537
public static void checkOnlineAndOfflineResultsMatch(
538-
CollectionReference collection, Query query, String... expectedDocs) {
538+
Query collection, Query query, String... expectedDocs) {
539539
// Note: Order matters. The following has to be done in the specific order:
540540

541541
// 1- Pre-populate the cache with the entire collection.

0 commit comments

Comments
 (0)