fix unit test

This commit is contained in:
valere 2023-05-31 10:42:46 +02:00
parent b59068b463
commit 2d335c1307
4 changed files with 9 additions and 4 deletions

View File

@ -19,6 +19,7 @@ package im.vector.app.core.device
import im.vector.app.test.fakes.FakeActiveSessionHolder
import im.vector.app.test.fakes.FakeCryptoService
import im.vector.app.test.fakes.FakeSession
import kotlinx.coroutines.runBlocking
import org.amshove.kluent.shouldBeEqualTo
import org.junit.Test
@ -32,7 +33,7 @@ class DefaultGetDeviceInfoUseCaseTest {
@Test
fun `when execute, then get crypto device info`() {
val result = getDeviceInfoUseCase.execute()
val result = runBlocking { getDeviceInfoUseCase.execute() }
result shouldBeEqualTo cryptoService.cryptoDeviceInfo
}

View File

@ -29,6 +29,7 @@ import im.vector.app.test.fixtures.CryptoDeviceInfoFixture.aCryptoDeviceInfo
import im.vector.app.test.fixtures.PusherFixture
import im.vector.app.test.fixtures.SessionParamsFixture
import io.mockk.mockk
import kotlinx.coroutines.runBlocking
import org.amshove.kluent.shouldBeEqualTo
import org.junit.Test
import org.matrix.android.sdk.api.session.crypto.model.UnsignedDeviceInfo
@ -80,7 +81,9 @@ class PushersManagerTest {
withEventIdOnly = true,
)
pushersManager.enqueueRegisterPusher(pushKey, gateway)
runBlocking {
pushersManager.enqueueRegisterPusher(pushKey, gateway)
}
val httpPusher = pushersService.verifyEnqueueAddHttpPusher()
httpPusher shouldBeEqualTo expectedHttpPusher

View File

@ -84,5 +84,5 @@ class FakeCryptoService(
}
}
override fun getMyCryptoDevice() = cryptoDeviceInfo
override suspend fun getMyCryptoDevice() = cryptoDeviceInfo
}

View File

@ -17,6 +17,7 @@
package im.vector.app.test.fakes
import im.vector.app.core.device.GetDeviceInfoUseCase
import io.mockk.coEvery
import io.mockk.every
import io.mockk.mockk
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
@ -24,6 +25,6 @@ import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
class FakeGetDeviceInfoUseCase : GetDeviceInfoUseCase by mockk() {
fun givenDeviceInfo(cryptoDeviceInfo: CryptoDeviceInfo) {
every { execute() } returns cryptoDeviceInfo
coEvery { execute() } returns cryptoDeviceInfo
}
}