mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 11:20:47 +01:00
Remove cruft around SignalAccountRecord.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.storage
|
||||
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import okio.ByteString
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.junit.Test
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.whispersystems.signalservice.api.storage.SignalAccountRecord
|
||||
import org.whispersystems.signalservice.api.storage.SignalContactRecord
|
||||
import org.whispersystems.signalservice.api.storage.StorageId
|
||||
import org.whispersystems.signalservice.internal.storage.protos.AccountRecord
|
||||
import org.whispersystems.signalservice.internal.storage.protos.ContactRecord
|
||||
|
||||
class StorageRecordTest {
|
||||
|
||||
@Test
|
||||
fun `describeDiff - general test`() {
|
||||
val a = SignalAccountRecord(
|
||||
StorageId.forAccount(Util.getSecretBytes(16)),
|
||||
AccountRecord(
|
||||
profileKey = ByteString.EMPTY,
|
||||
givenName = "First",
|
||||
familyName = "Last"
|
||||
)
|
||||
)
|
||||
|
||||
val b = SignalAccountRecord(
|
||||
StorageId.forAccount(Util.getSecretBytes(16)),
|
||||
AccountRecord(
|
||||
profileKey = Util.getSecretBytes(16).toByteString(),
|
||||
givenName = "First",
|
||||
familyName = "LastB"
|
||||
)
|
||||
)
|
||||
|
||||
assertEquals("Some fields differ: familyName, id, profileKey", a.describeDiff(b))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `describeDiff - different class`() {
|
||||
val a = SignalAccountRecord(
|
||||
StorageId.forAccount(Util.getSecretBytes(16)),
|
||||
AccountRecord()
|
||||
)
|
||||
|
||||
val b = SignalContactRecord(
|
||||
StorageId.forAccount(Util.getSecretBytes(16)),
|
||||
ContactRecord()
|
||||
)
|
||||
|
||||
assertEquals("Classes are different!", a.describeDiff(b))
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public final class StorageSyncHelperTest {
|
||||
.setProfileGivenName(profileName);
|
||||
}
|
||||
|
||||
private static <E extends SignalRecord> StorageRecordUpdate<E> update(E oldRecord, E newRecord) {
|
||||
private static <E extends SignalRecord<?>> StorageRecordUpdate<E> update(E oldRecord, E newRecord) {
|
||||
return new StorageRecordUpdate<>(oldRecord, newRecord);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user