Cleanup tests.
This commit is contained in:
parent
75a640b986
commit
025131841b
9 changed files with 64 additions and 58 deletions
|
|
@ -23,11 +23,12 @@ import org.junit.Test
|
|||
class RustClientSessionDelegateTest {
|
||||
@Test
|
||||
fun `saveSessionInKeychain should update the store`() = runTest {
|
||||
val sessionStore = InMemorySessionStore()
|
||||
sessionStore.storeData(
|
||||
aSessionData(
|
||||
accessToken = "anAccessToken",
|
||||
refreshToken = "aRefreshToken",
|
||||
val sessionStore = InMemorySessionStore(
|
||||
initialList = listOf(
|
||||
aSessionData(
|
||||
accessToken = "anAccessToken",
|
||||
refreshToken = "aRefreshToken",
|
||||
)
|
||||
)
|
||||
)
|
||||
val sut = aRustClientSessionDelegate(sessionStore)
|
||||
|
|
|
|||
|
|
@ -24,14 +24,15 @@ class SessionPathsProviderTest {
|
|||
|
||||
@Test
|
||||
fun `if session is found, provides returns the data`() = runTest {
|
||||
val store = InMemorySessionStore()
|
||||
val sut = SessionPathsProvider(store)
|
||||
store.storeData(
|
||||
aSessionData(
|
||||
sessionPath = "/a/path/to/a/session",
|
||||
cachePath = "/a/path/to/a/cache",
|
||||
val store = InMemorySessionStore(
|
||||
initialList = listOf(
|
||||
aSessionData(
|
||||
sessionPath = "/a/path/to/a/session",
|
||||
cachePath = "/a/path/to/a/cache",
|
||||
)
|
||||
)
|
||||
)
|
||||
val sut = SessionPathsProvider(store)
|
||||
val result = sut.provides(A_SESSION_ID)!!
|
||||
assertThat(result.fileDirectory.absolutePath).isEqualTo("/a/path/to/a/session")
|
||||
assertThat(result.cacheDirectory.absolutePath).isEqualTo("/a/path/to/a/cache")
|
||||
|
|
|
|||
|
|
@ -49,11 +49,13 @@ class DefaultFirebaseNewTokenHandlerTest {
|
|||
val registerPusherResult = lambdaRecorder<MatrixClient, String, String, Result<Unit>> { _, _, _ -> Result.success(Unit) }
|
||||
val pusherSubscriber = FakePusherSubscriber(registerPusherResult = registerPusherResult)
|
||||
val firebaseNewTokenHandler = createDefaultFirebaseNewTokenHandler(
|
||||
sessionStore = InMemorySessionStore().apply {
|
||||
storeData(aSessionData(A_USER_ID.value))
|
||||
storeData(aSessionData(A_USER_ID_2.value))
|
||||
storeData(aSessionData(A_USER_ID_3.value))
|
||||
},
|
||||
sessionStore = InMemorySessionStore(
|
||||
initialList = listOf(
|
||||
aSessionData(A_USER_ID.value),
|
||||
aSessionData(A_USER_ID_2.value),
|
||||
aSessionData(A_USER_ID_3.value),
|
||||
)
|
||||
),
|
||||
matrixClientProvider = FakeMatrixClientProvider { sessionId ->
|
||||
when (sessionId) {
|
||||
A_USER_ID -> Result.success(aMatrixClient1)
|
||||
|
|
@ -88,9 +90,9 @@ class DefaultFirebaseNewTokenHandlerTest {
|
|||
val registerPusherResult = lambdaRecorder<MatrixClient, String, String, Result<Unit>> { _, _, _ -> Result.success(Unit) }
|
||||
val pusherSubscriber = FakePusherSubscriber(registerPusherResult = registerPusherResult)
|
||||
val firebaseNewTokenHandler = createDefaultFirebaseNewTokenHandler(
|
||||
sessionStore = InMemorySessionStore().apply {
|
||||
storeData(aSessionData(A_USER_ID.value))
|
||||
},
|
||||
sessionStore = InMemorySessionStore(
|
||||
initialList = listOf(aSessionData(A_USER_ID.value))
|
||||
),
|
||||
matrixClientProvider = FakeMatrixClientProvider {
|
||||
Result.failure(IllegalStateException())
|
||||
},
|
||||
|
|
@ -112,9 +114,9 @@ class DefaultFirebaseNewTokenHandlerTest {
|
|||
val registerPusherResult = lambdaRecorder<MatrixClient, String, String, Result<Unit>> { _, _, _ -> Result.failure(AN_EXCEPTION) }
|
||||
val pusherSubscriber = FakePusherSubscriber(registerPusherResult = registerPusherResult)
|
||||
val firebaseNewTokenHandler = createDefaultFirebaseNewTokenHandler(
|
||||
sessionStore = InMemorySessionStore().apply {
|
||||
storeData(aSessionData(A_USER_ID.value))
|
||||
},
|
||||
sessionStore = InMemorySessionStore(
|
||||
initialList = listOf(aSessionData(A_USER_ID.value))
|
||||
),
|
||||
matrixClientProvider = FakeMatrixClientProvider {
|
||||
Result.success(aMatrixClient1)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
class InMemorySessionStore : SessionStore {
|
||||
private val sessionDataListFlow = MutableStateFlow<List<SessionData>>(emptyList())
|
||||
class InMemorySessionStore(
|
||||
initialList: List<SessionData> = emptyList(),
|
||||
) : SessionStore {
|
||||
private val sessionDataListFlow = MutableStateFlow(initialList)
|
||||
|
||||
override fun isLoggedIn(): Flow<LoggedInState> {
|
||||
return sessionDataListFlow.map {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue