Add test for MatrixClientsHolder

This commit is contained in:
Benoit Marty 2023-09-29 15:34:02 +02:00
parent cd1039ef54
commit 37249261e1
2 changed files with 103 additions and 1 deletions

View file

@ -36,6 +36,7 @@ class FakeAuthenticationService : MatrixAuthenticationService {
private var oidcCancelError: Throwable? = null
private var loginError: Throwable? = null
private var changeServerError: Throwable? = null
private var matrixClient: MatrixClient? = null
override fun isLoggedIn(): Flow<Boolean> {
return flowOf(false)
@ -46,7 +47,11 @@ class FakeAuthenticationService : MatrixAuthenticationService {
}
override suspend fun restoreSession(sessionId: SessionId): Result<MatrixClient> {
return Result.failure(IllegalStateException())
return if (matrixClient != null) {
Result.success(matrixClient!!)
} else {
Result.failure(IllegalStateException())
}
}
override fun getHomeserverDetails(): StateFlow<MatrixHomeServerDetails?> {
@ -92,4 +97,8 @@ class FakeAuthenticationService : MatrixAuthenticationService {
fun givenChangeServerError(throwable: Throwable?) {
changeServerError = throwable
}
fun givenMatrixClient(matrixClient: MatrixClient) {
this.matrixClient = matrixClient
}
}