Skip to content

Commit ac5cf99

Browse files
committed
code review
1 parent dcbdb54 commit ac5cf99

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

docs/database_migration_test.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
<!--- TOC -->
2+
3+
* [Testing database migration](#testing-database-migration)
4+
* [Creating a reference database](#creating-a-reference-database)
5+
* [Testing](#testing)
6+
7+
<!--- END -->
8+
19
## Testing database migration
210

311
### Creating a reference database
412

513
Databases are encrypted, the key to decrypt is needed to setup the test.
614
A special build property must be enabled to extract it.
715

8-
Set `vector.debugPrivateData=true` in `gradle.properties`
16+
Set `vector.debugPrivateData=true` in `~/.gradle/gradle.properties` (to avoid committing by mistake)
917

10-
Launch the app in your emulator, login and use the app to feel up the database.
18+
Launch the app in your emulator, login and use the app to fill up the database.
1119

1220
Save the key for the tested database
1321
```
@@ -20,8 +28,8 @@ Use the [Device File Explorer](https://developer.android.com/studio/debug/device
2028

2129
Go to `data/data/im.vector.app.debug/files/<hash>/`
2230
Pick the database you want to test (name can be found in SessionRealmConfigurationFactory):
23-
- crypto_store.real for crypto
24-
- disk_store for session
31+
- crypto_store.realm for crypto
32+
- disk_store.realm for session
2533
- etc...
2634

2735
Download the file on your disk
@@ -33,7 +41,7 @@ Copy the file in `src/AndroidTest/assets`
3341
see `CryptoSanityMigrationTest` or `RealmSessionStoreMigration43Test` for sample tests.
3442

3543
There are already some databases in the assets folder.
36-
The existing test will properly detect schema changes, and fail with such errors:
44+
The existing test will properly detect schema changes, and fail with such errors if a migration is missing:
3745

3846
```
3947
io.realm.exceptions.RealmMigrationNeededException: Migration is required due to the following errors:

matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/database/CryptoSanityMigrationTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CryptoSanityMigrationTest {
4848
val realmName = "crypto_store_20.realm"
4949
val migration = RealmCryptoStoreMigration(object : Clock {
5050
override fun epochMillis(): Long {
51-
return System.currentTimeMillis()
51+
return 0L
5252
}
5353
})
5454
val realmConfiguration = configurationFactory.createConfiguration(

0 commit comments

Comments
 (0)