mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 03:16:02 +03:00
ensuring the store migration class is always equal to other store migration instances
- is needed as realm will throw if multiple migration instances are created and they don't match
This commit is contained in:
parent
540036f83c
commit
9949779b62
2 changed files with 36 additions and 0 deletions
|
@ -57,6 +57,13 @@ internal class RealmSessionStoreMigration @Inject constructor(
|
|||
const val SESSION_STORE_SCHEMA_VERSION = 19L
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces all RealmSessionStoreMigration instances to be equal
|
||||
* Avoids Realm throwing when multiple instances of the migration are set
|
||||
*/
|
||||
override fun equals(other: Any?) = other is RealmSessionStoreMigration
|
||||
override fun hashCode() = 1000
|
||||
|
||||
override fun migrate(realm: DynamicRealm, oldVersion: Long, newVersion: Long) {
|
||||
Timber.v("Migrating Realm Session from $oldVersion to $newVersion")
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.database
|
||||
|
||||
import io.mockk.mockk
|
||||
import org.amshove.kluent.shouldBeEqualTo
|
||||
import org.junit.Test
|
||||
|
||||
class RealmSessionStoreMigrationTest {
|
||||
|
||||
@Test
|
||||
fun `when creating multiple migration instances then they are equal`() {
|
||||
RealmSessionStoreMigration(normalizer = mockk()) shouldBeEqualTo RealmSessionStoreMigration(normalizer = mockk())
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue