Skip to content

Commit 6ddff9c

Browse files
committed
SQLiteSchemaTest.java: add a test
1 parent ee68441 commit 6ddff9c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,27 @@ public void createsOverlaysAndMigrationTable() {
702702
assertEquals(Persistence.DATA_MIGRATION_BUILD_OVERLAYS, migrationName);
703703
}
704704

705+
@Test
706+
public void existingDocumentsMatchAfterRemoteDocumentsDocumentTypeColumnAdded() {
707+
schema.runSchemaUpgrades(0, 1);
708+
for (int i = 0; i < 3; i++) {
709+
db.execSQL(
710+
"INSERT INTO remote_documents (path, contents) VALUES (?, ?)",
711+
new Object[] {encode(path("coll/doc" + i)), createDummyDocument("coll/doc" + i)});
712+
}
713+
714+
// The migration of interest is 18, but go to the latest migration to ensure compatibility with
715+
// the SQLiteRemoteDocumentCache implementation.
716+
schema.runSchemaUpgrades(2, VERSION);
717+
718+
SQLiteRemoteDocumentCache remoteDocumentCache = createRemoteDocumentCache();
719+
720+
Map<DocumentKey, MutableDocument> results =
721+
remoteDocumentCache.getDocumentsMatchingQuery(
722+
query("coll"), IndexOffset.NONE, new HashSet<DocumentKey>());
723+
assertResultsContain(results, "coll/doc0", "coll/doc1", "coll/doc2");
724+
}
725+
705726
private SQLiteRemoteDocumentCache createRemoteDocumentCache() {
706727
SQLitePersistence persistence =
707728
new SQLitePersistence(serializer, LruGarbageCollector.Params.Default(), opener);

0 commit comments

Comments
 (0)