Add test on pusher registration

This commit is contained in:
Benoit Marty 2024-06-14 17:26:06 +02:00 committed by Benoit Marty
parent 9097d73f38
commit 3eaf780087
4 changed files with 311 additions and 6 deletions

View file

@ -28,9 +28,10 @@ class FakePushService(
private val registerWithLambda: suspend (MatrixClient, PushProvider, Distributor) -> Result<Unit> = { _, _, _ ->
Result.success(Unit)
},
private val currentPushProvider: () -> PushProvider? = { availablePushProviders.firstOrNull() },
) : PushService {
override suspend fun getCurrentPushProvider(): PushProvider? {
return registeredPushProvider ?: availablePushProviders.firstOrNull()
return registeredPushProvider ?: currentPushProvider()
}
override fun getAvailablePushProviders(): List<PushProvider> {

View file

@ -27,6 +27,7 @@ class FakePushProvider(
override val name: String = "aFakePushProvider",
private val isAvailable: Boolean = true,
private val distributors: List<Distributor> = listOf(Distributor("aDistributorValue", "aDistributorName")),
private val currentDistributor: () -> Distributor? = { distributors.firstOrNull() },
private val currentUserPushConfig: CurrentUserPushConfig? = null,
private val registerWithResult: (MatrixClient, Distributor) -> Result<Unit> = { _, _ -> lambdaError() },
private val unregisterWithResult: (MatrixClient) -> Result<Unit> = { lambdaError() },
@ -40,7 +41,7 @@ class FakePushProvider(
}
override suspend fun getCurrentDistributor(matrixClient: MatrixClient): Distributor? {
return distributors.firstOrNull()
return currentDistributor()
}
override suspend fun unregister(matrixClient: MatrixClient): Result<Unit> {