From ac5cf9976d56921d286f0f89930194bc6461fe6e Mon Sep 17 00:00:00 2001 From: valere Date: Wed, 7 Dec 2022 10:48:32 +0100 Subject: [PATCH] code review --- docs/database_migration_test.md | 18 +++++++++++++----- .../database/CryptoSanityMigrationTest.kt | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/database_migration_test.md b/docs/database_migration_test.md index 44c4504204d..f7844abde8a 100644 --- a/docs/database_migration_test.md +++ b/docs/database_migration_test.md @@ -1,3 +1,11 @@ + + +* [Testing database migration](#testing-database-migration) + * [Creating a reference database](#creating-a-reference-database) + * [Testing](#testing) + + + ## Testing database migration ### Creating a reference database @@ -5,9 +13,9 @@ Databases are encrypted, the key to decrypt is needed to setup the test. A special build property must be enabled to extract it. -Set `vector.debugPrivateData=true` in `gradle.properties` +Set `vector.debugPrivateData=true` in `~/.gradle/gradle.properties` (to avoid committing by mistake) -Launch the app in your emulator, login and use the app to feel up the database. +Launch the app in your emulator, login and use the app to fill up the database. Save the key for the tested database ``` @@ -20,8 +28,8 @@ Use the [Device File Explorer](https://developer.android.com/studio/debug/device Go to `data/data/im.vector.app.debug/files//` Pick the database you want to test (name can be found in SessionRealmConfigurationFactory): - - crypto_store.real for crypto - - disk_store for session + - crypto_store.realm for crypto + - disk_store.realm for session - etc... Download the file on your disk @@ -33,7 +41,7 @@ Copy the file in `src/AndroidTest/assets` see `CryptoSanityMigrationTest` or `RealmSessionStoreMigration43Test` for sample tests. There are already some databases in the assets folder. -The existing test will properly detect schema changes, and fail with such errors: +The existing test will properly detect schema changes, and fail with such errors if a migration is missing: ``` io.realm.exceptions.RealmMigrationNeededException: Migration is required due to the following errors: diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/database/CryptoSanityMigrationTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/database/CryptoSanityMigrationTest.kt index 98311332f10..2643bf643a0 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/database/CryptoSanityMigrationTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/database/CryptoSanityMigrationTest.kt @@ -48,7 +48,7 @@ class CryptoSanityMigrationTest { val realmName = "crypto_store_20.realm" val migration = RealmCryptoStoreMigration(object : Clock { override fun epochMillis(): Long { - return System.currentTimeMillis() + return 0L } }) val realmConfiguration = configurationFactory.createConfiguration(