Make LogoutUseCase.logout return the result of the SDK method.
This commit is contained in:
parent
76a3ef9353
commit
329c0670ed
5 changed files with 10 additions and 9 deletions
|
|
@ -106,7 +106,7 @@ class PinUnlockPresenterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - forgot pin flow`() = runTest {
|
fun `present - forgot pin flow`() = runTest {
|
||||||
val signOutLambda = lambdaRecorder<Boolean, String> { "" }
|
val signOutLambda = lambdaRecorder<Boolean, String?> { "" }
|
||||||
val signOut = FakeLogoutUseCase(signOutLambda)
|
val signOut = FakeLogoutUseCase(signOutLambda)
|
||||||
val presenter = createPinUnlockPresenter(this, logoutUseCase = signOut)
|
val presenter = createPinUnlockPresenter(this, logoutUseCase = signOut)
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,10 @@ interface LogoutUseCase {
|
||||||
/**
|
/**
|
||||||
* Log out the current user and then perform any needed cleanup tasks.
|
* Log out the current user and then perform any needed cleanup tasks.
|
||||||
* @param ignoreSdkError if true, the SDK error will be ignored and the user will be logged out anyway.
|
* @param ignoreSdkError if true, the SDK error will be ignored and the user will be logged out anyway.
|
||||||
* @return the session id of the logged out user.
|
* @return an optional URL. When the URL is there, it should be presented to the user after logout for
|
||||||
|
* Relying Party (RP) initiated logout on their account page.
|
||||||
*/
|
*/
|
||||||
suspend fun logout(ignoreSdkError: Boolean): String
|
suspend fun logout(ignoreSdkError: Boolean): String?
|
||||||
|
|
||||||
interface Factory {
|
interface Factory {
|
||||||
fun create(sessionId: String): LogoutUseCase
|
fun create(sessionId: String): LogoutUseCase
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,9 @@ class DefaultLogoutUseCase @AssistedInject constructor(
|
||||||
override fun create(sessionId: String): DefaultLogoutUseCase
|
override fun create(sessionId: String): DefaultLogoutUseCase
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun logout(ignoreSdkError: Boolean): String {
|
override suspend fun logout(ignoreSdkError: Boolean): String? {
|
||||||
val matrixClient = matrixClientProvider.getOrRestore(SessionId(sessionId)).getOrThrow()
|
val matrixClient = matrixClientProvider.getOrRestore(SessionId(sessionId)).getOrThrow()
|
||||||
matrixClient.logout(ignoreSdkError = ignoreSdkError)
|
val result = matrixClient.logout(ignoreSdkError = ignoreSdkError)
|
||||||
return sessionId
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ import io.element.android.features.logout.api.LogoutUseCase
|
||||||
import io.element.android.tests.testutils.lambda.lambdaError
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
|
||||||
class FakeLogoutUseCase(
|
class FakeLogoutUseCase(
|
||||||
var logoutLambda: (Boolean) -> String = lambdaError()
|
var logoutLambda: (Boolean) -> String? = { lambdaError() }
|
||||||
) : LogoutUseCase {
|
) : LogoutUseCase {
|
||||||
override suspend fun logout(ignoreSdkError: Boolean): String {
|
override suspend fun logout(ignoreSdkError: Boolean): String? {
|
||||||
return logoutLambda(ignoreSdkError)
|
return logoutLambda(ignoreSdkError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ class DeveloperSettingsPresenterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - toggling simplified sliding sync changes the preferences and logs out the user`() = runTest {
|
fun `present - toggling simplified sliding sync changes the preferences and logs out the user`() = runTest {
|
||||||
val logoutCallRecorder = lambdaRecorder<Boolean, String> { "" }
|
val logoutCallRecorder = lambdaRecorder<Boolean, String?> { "" }
|
||||||
val logoutUseCase = FakeLogoutUseCase(logoutLambda = logoutCallRecorder)
|
val logoutUseCase = FakeLogoutUseCase(logoutLambda = logoutCallRecorder)
|
||||||
val preferences = InMemoryAppPreferencesStore()
|
val preferences = InMemoryAppPreferencesStore()
|
||||||
val presenter = createDeveloperSettingsPresenter(preferencesStore = preferences, logoutUseCase = logoutUseCase)
|
val presenter = createDeveloperSettingsPresenter(preferencesStore = preferences, logoutUseCase = logoutUseCase)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue