Added tests for migration legacy to room#6797
Added tests for migration legacy to room#6797RitikaPahwa4444 merged 7 commits intocommons-app:mainfrom
Conversation
RitikaPahwa4444
left a comment
There was a problem hiding this comment.
Thanks @rovertrack. I'm reviewing the tests. Meanwhile, could you check the comment I added?
|
@RitikaPahwa4444 please check the latest commit wrote MigrationTest.kt which proves that the migration from old legacy db to room db is done suucessfully before :
also completes #6798 please review this, thanks |
RitikaPahwa4444
left a comment
There was a problem hiding this comment.
Mostly looks good. I'll test it once and merge.
There was a problem hiding this comment.
Pull request overview
Adds Robolectric/Room-based tests and wiring to support verifying interoperability and migration between the legacy commons.db (content-provider tables) and the Room database as part of the ongoing “content providers → Room” migration plan (issue #6777, parent #6768).
Changes:
- Introduces an
InMemoryDatabaseTestbase to run Room in-memory DB tests and execute legacy SQL against the same DB. - Adds per-table tests for legacy table compatibility with new Room entities/DAOs (categories, bookmarks, bookmark items, recent searches, recent languages).
- Bumps Room DB to v22, adds new Room entities/DAOs, and adds a
MIGRATION_21_22intended to copy data fromcommons.db→commons_room.db.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/test/kotlin/fr/free/nrw/commons/db/InMemoryDatabaseTest.kt | Base test harness for Room in-memory DB + legacy SQL helpers |
| app/src/test/kotlin/fr/free/nrw/commons/db/CategoryTableTest.kt | Category legacy↔Room compatibility tests |
| app/src/test/kotlin/fr/free/nrw/commons/db/BookmarkPictureTableTest.kt | Bookmark pictures legacy↔Room compatibility tests |
| app/src/test/kotlin/fr/free/nrw/commons/db/BookmarkItemsTableTest.kt | Bookmark items legacy↔Room compatibility tests |
| app/src/test/kotlin/fr/free/nrw/commons/db/RecentSearchesTableTest.kt | Recent searches legacy↔Room compatibility tests |
| app/src/test/kotlin/fr/free/nrw/commons/db/RecentLanguagesTableTest.kt | Recent languages legacy↔Room compatibility tests |
| app/src/test/kotlin/fr/free/nrw/commons/db/MigrationTest.kt | Adds a Robolectric test intended to validate the 21→22 migration |
| app/src/main/java/fr/free/nrw/commons/db/AppDatabase.kt | Adds new entities/DAOs to Room DB and bumps version to 22 |
| app/src/main/java/fr/free/nrw/commons/di/CommonsApplicationModule.kt | Registers MIGRATION_21_22 and implements data-copy migration logic |
| app/src/main/java/fr/free/nrw/commons/data/DBOpenHelper.kt | Allows injecting a delegate openHelper for tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@RitikaPahwa4444 I have made the improvements suggested by copilot |
|
Thanks @RitikaPahwa4444 |
|
✅ Generated APK variants! |
* added tests for migration legacy to room * added data migration from commons.db to commons_room.db * changes * assertion changes --------- Co-authored-by: Ritika Pahwa <83745993+RitikaPahwa4444@users.noreply.github.com>


Fixes #6777
relates to parent: #6768
What changes did you make and why?
added the inmemorydatabasebuilder helper class thanks to @psh comment
added tests
all implemented tests passed ✅