Skip to content

Commit 52cb627

Browse files
committed
add test coverage
1 parent 4c7d5aa commit 52cb627

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ public void testAutoIndexCreationSetSuccessfully() {
118118
.build();
119119
db.setFirestoreSettings(settings);
120120

121-
// Based on current heuristic, collection document counts (3) > 2 * resultSize (1).
122121
CollectionReference collection =
123122
testCollectionWithDocs(
124123
map(
@@ -147,7 +146,6 @@ public void testAutoIndexCreationSetSuccessfullyUsingDefault() {
147146
// Use persistent disk cache (default)
148147
FirebaseFirestore db = testFirestore();
149148

150-
// Based on current heuristic, collection document counts (3) > 2 * resultSize (1).
151149
CollectionReference collection =
152150
testCollectionWithDocs(
153151
map(
@@ -183,5 +181,9 @@ public void testAutoIndexCreationAfterFailsTermination() {
183181
expectError(
184182
() -> db.getPersistentCacheIndexManager().disableIndexAutoCreation(),
185183
"The client has already been terminated");
184+
185+
expectError(
186+
() -> db.getPersistentCacheIndexManager().deleteAllIndexes(),
187+
"The client has already been terminated");
186188
}
187189
}

firebase-firestore/src/main/java/com/google/firebase/firestore/PersistentCacheIndexManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void disableIndexAutoCreation() {
5454

5555
/**
5656
* Removes all persistent cache indexes. Please note this function will also deletes indexes
57-
* generated by {@link FirebaseFirestore#setIndexConfiguration(String)}.
57+
* generated by {@link FirebaseFirestore#setIndexConfiguration(String)}, which is deprecated.
5858
*/
5959
public void deleteAllIndexes() {
6060
client.deleteAllFieldIndexes();

firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteLocalStoreTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -577,16 +577,18 @@ public void testDisableIndexAutoCreationWorks() {
577577

578578
@Test
579579
public void testDeleteAllIndexesWorksWithIndexAutoCreation() {
580-
Query query = query("coll").filter(filter("matches", "==", true));
580+
Query query = query("coll").filter(filter("value", "==", "match"));
581581
int targetId = allocateQuery(query);
582582

583-
enableIndexAutoCreation();
583+
setIndexAutoCreationEnabled(true);
584+
setMinCollectionSizeToAutoCreateIndex(0);
585+
setRelativeIndexReadCostPerDocument(2);
584586

585-
applyRemoteEvent(addedRemoteEvent(doc("coll/a", 10, map("matches", true)), targetId));
586-
applyRemoteEvent(addedRemoteEvent(doc("coll/b", 10, map("matches", false)), targetId));
587-
applyRemoteEvent(addedRemoteEvent(doc("coll/c", 10, map("matches", false)), targetId));
588-
applyRemoteEvent(addedRemoteEvent(doc("coll/d", 10, map("matches", false)), targetId));
589-
applyRemoteEvent(addedRemoteEvent(doc("coll/e", 10, map("matches", true)), targetId));
587+
applyRemoteEvent(addedRemoteEvent(doc("coll/a", 10, map("value", "match")), targetId));
588+
applyRemoteEvent(addedRemoteEvent(doc("coll/b", 10, map("value", Double.NaN)), targetId));
589+
applyRemoteEvent(addedRemoteEvent(doc("coll/c", 10, map("value", null)), targetId));
590+
applyRemoteEvent(addedRemoteEvent(doc("coll/d", 10, map("value", "mismatch")), targetId));
591+
applyRemoteEvent(addedRemoteEvent(doc("coll/e", 10, map("value", "match")), targetId));
590592

591593
// First time query is running without indexes.
592594
// Based on current heuristic, collection document counts (5) > 2 * resultSize (2).
@@ -595,7 +597,7 @@ public void testDeleteAllIndexesWorksWithIndexAutoCreation() {
595597
assertRemoteDocumentsRead(/* byKey= */ 0, /* byCollection= */ 2);
596598
assertQueryReturned("coll/a", "coll/e");
597599

598-
disableIndexAutoCreation();
600+
setIndexAutoCreationEnabled(false);
599601

600602
backfillIndexes();
601603

0 commit comments

Comments
 (0)