Use aSessionData() from the test module.
And fix typo.
This commit is contained in:
parent
619841fc80
commit
5de84f6ad8
4 changed files with 13 additions and 29 deletions
|
|
@ -55,6 +55,7 @@ dependencies {
|
|||
testImplementation(libs.test.mockk)
|
||||
testImplementation(projects.libraries.matrix.test)
|
||||
testImplementation(projects.libraries.sessionStorage.implMemory)
|
||||
testImplementation(projects.libraries.sessionStorage.test)
|
||||
testImplementation(projects.features.rageshake.test)
|
||||
testImplementation(projects.tests.testutils)
|
||||
testImplementation(projects.services.toolbox.test)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,8 @@ import io.element.android.libraries.matrix.test.FakeSdkMetadata
|
|||
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||
import io.element.android.libraries.matrix.test.encryption.FakeEncryptionService
|
||||
import io.element.android.libraries.network.useragent.DefaultUserAgentProvider
|
||||
import io.element.android.libraries.sessionstorage.api.LoginType
|
||||
import io.element.android.libraries.sessionstorage.api.SessionData
|
||||
import io.element.android.libraries.sessionstorage.impl.memory.InMemorySessionStore
|
||||
import io.element.android.libraries.sessionstorage.test.aSessionData
|
||||
import io.element.android.tests.testutils.testCoroutineDispatchers
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import kotlinx.coroutines.test.runTest
|
||||
|
|
@ -94,7 +93,7 @@ class DefaultBugReporterTest {
|
|||
server.start()
|
||||
|
||||
val mockSessionStore = InMemorySessionStore().apply {
|
||||
storeData(mockSessionData("@foo:eample.com", "ABCDEFGH"))
|
||||
storeData(aSessionData(sessionId = "@foo:example.com", deviceId = "ABCDEFGH"))
|
||||
}
|
||||
|
||||
val buildMeta = aBuildMeta()
|
||||
|
|
@ -143,7 +142,7 @@ class DefaultBugReporterTest {
|
|||
assertThat(foundValues["can_contact"]).isEqualTo("true")
|
||||
assertThat(foundValues["device_id"]).isEqualTo("ABCDEFGH")
|
||||
assertThat(foundValues["sdk_sha"]).isEqualTo("123456789")
|
||||
assertThat(foundValues["user_id"]).isEqualTo("@foo:eample.com")
|
||||
assertThat(foundValues["user_id"]).isEqualTo("@foo:example.com")
|
||||
assertThat(foundValues["text"]).isEqualTo("a bug occurred")
|
||||
assertThat(foundValues["device_keys"]).isEqualTo("curve25519:CURVECURVECURVE, ed25519:EDKEYEDKEYEDKY")
|
||||
|
||||
|
|
@ -163,7 +162,7 @@ class DefaultBugReporterTest {
|
|||
server.start()
|
||||
|
||||
val mockSessionStore = InMemorySessionStore().apply {
|
||||
storeData(mockSessionData("@foo:eample.com", "ABCDEFGH"))
|
||||
storeData(aSessionData("@foo:example.com", "ABCDEFGH"))
|
||||
}
|
||||
|
||||
val buildMeta = aBuildMeta()
|
||||
|
|
@ -267,21 +266,6 @@ class DefaultBugReporterTest {
|
|||
return foundValues
|
||||
}
|
||||
|
||||
private fun mockSessionData(userId: String, deviceId: String) = SessionData(
|
||||
userId = userId,
|
||||
deviceId = deviceId,
|
||||
homeserverUrl = "example.com",
|
||||
accessToken = "AA",
|
||||
isTokenValid = true,
|
||||
loginType = LoginType.DIRECT,
|
||||
loginTimestamp = null,
|
||||
oidcData = null,
|
||||
refreshToken = null,
|
||||
slidingSyncProxy = null,
|
||||
passphrase = null,
|
||||
sessionPath = "session",
|
||||
cachePath = "cache",
|
||||
)
|
||||
@Test
|
||||
fun `test sendBugReport error`() = runTest {
|
||||
val server = MockWebServer()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
package io.element.android.features.signedout.impl
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.sessionstorage.api.LoginType
|
||||
import io.element.android.libraries.sessionstorage.api.SessionData
|
||||
|
||||
|
|
@ -20,18 +19,18 @@ open class SignedOutStateProvider : PreviewParameterProvider<SignedOutState> {
|
|||
)
|
||||
}
|
||||
|
||||
fun aSignedOutState() = SignedOutState(
|
||||
private fun aSignedOutState() = SignedOutState(
|
||||
appName = "AppName",
|
||||
signedOutSession = aSessionData(),
|
||||
eventSink = {},
|
||||
)
|
||||
|
||||
fun aSessionData(
|
||||
sessionId: SessionId = SessionId("@alice:server.org"),
|
||||
private fun aSessionData(
|
||||
sessionId: String = "@alice:server.org",
|
||||
isTokenValid: Boolean = false,
|
||||
): SessionData {
|
||||
return SessionData(
|
||||
userId = sessionId.value,
|
||||
userId = sessionId,
|
||||
deviceId = "aDeviceId",
|
||||
accessToken = "anAccessToken",
|
||||
refreshToken = "aRefreshToken",
|
||||
|
|
|
|||
|
|
@ -7,19 +7,19 @@
|
|||
|
||||
package io.element.android.libraries.sessionstorage.test
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.sessionstorage.api.LoginType
|
||||
import io.element.android.libraries.sessionstorage.api.SessionData
|
||||
|
||||
fun aSessionData(
|
||||
sessionId: SessionId = SessionId("@alice:server.org"),
|
||||
sessionId: String = "@alice:server.org",
|
||||
deviceId: String = "aDeviceId",
|
||||
isTokenValid: Boolean = false,
|
||||
sessionPath: String = "/a/path/to/a/session",
|
||||
cachePath: String = "/a/path/to/a/cache",
|
||||
): SessionData {
|
||||
return SessionData(
|
||||
userId = sessionId.value,
|
||||
deviceId = "aDeviceId",
|
||||
userId = sessionId,
|
||||
deviceId = deviceId,
|
||||
accessToken = "anAccessToken",
|
||||
refreshToken = "aRefreshToken",
|
||||
homeserverUrl = "aHomeserverUrl",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue