From 3e05431e6f70bcdfc704814ee5b1bc8a9eb264ba Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Wed, 15 Jun 2022 14:56:00 +0200 Subject: [PATCH] Fixing unit tests --- .../location/DefaultLocationSharingServiceTest.kt | 12 +++++++----- .../DefaultStartLiveLocationShareTaskTest.kt | 5 +++-- .../location/DefaultStopLiveLocationShareTaskTest.kt | 5 ++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultLocationSharingServiceTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultLocationSharingServiceTest.kt index 003842be28..d9b3526bf5 100644 --- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultLocationSharingServiceTest.kt +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultLocationSharingServiceTest.kt @@ -27,6 +27,7 @@ import kotlinx.coroutines.test.runTest import org.amshove.kluent.shouldBeEqualTo import org.junit.After import org.junit.Test +import org.matrix.android.sdk.api.session.room.location.UpdateLiveLocationShareResult import org.matrix.android.sdk.api.session.room.model.livelocation.LiveLocationShareAggregatedSummary import org.matrix.android.sdk.api.util.Cancelable import org.matrix.android.sdk.internal.database.mapper.LiveLocationShareAggregatedSummaryMapper @@ -119,11 +120,11 @@ internal class DefaultLocationSharingServiceTest { @Test fun `live location share can be started with a given timeout`() = runTest { - coEvery { startLiveLocationShareTask.execute(any()) } returns AN_EVENT_ID + coEvery { startLiveLocationShareTask.execute(any()) } returns UpdateLiveLocationShareResult.Success(AN_EVENT_ID) - val eventId = defaultLocationSharingService.startLiveLocationShare(A_TIMEOUT) + val result = defaultLocationSharingService.startLiveLocationShare(A_TIMEOUT) - eventId shouldBeEqualTo AN_EVENT_ID + result shouldBeEqualTo UpdateLiveLocationShareResult.Success(AN_EVENT_ID) val expectedParams = StartLiveLocationShareTask.Params( roomId = A_ROOM_ID, timeoutMillis = A_TIMEOUT @@ -133,10 +134,11 @@ internal class DefaultLocationSharingServiceTest { @Test fun `live location share can be stopped`() = runTest { - coEvery { stopLiveLocationShareTask.execute(any()) } just runs + coEvery { stopLiveLocationShareTask.execute(any()) } returns UpdateLiveLocationShareResult.Success(AN_EVENT_ID) - defaultLocationSharingService.stopLiveLocationShare() + val result = defaultLocationSharingService.stopLiveLocationShare() + result shouldBeEqualTo UpdateLiveLocationShareResult.Success(AN_EVENT_ID) val expectedParams = StopLiveLocationShareTask.Params( roomId = A_ROOM_ID ) diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultStartLiveLocationShareTaskTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultStartLiveLocationShareTaskTest.kt index c435e60db3..6a487a4e81 100644 --- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultStartLiveLocationShareTaskTest.kt +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultStartLiveLocationShareTaskTest.kt @@ -24,6 +24,7 @@ import org.junit.After import org.junit.Test import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.events.model.toContent +import org.matrix.android.sdk.api.session.room.location.UpdateLiveLocationShareResult import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent import org.matrix.android.sdk.internal.session.room.state.SendStateTask import org.matrix.android.sdk.test.fakes.FakeClock @@ -53,7 +54,7 @@ internal class DefaultStartLiveLocationShareTaskTest { } @Test - fun `given parameters when calling the task then it is correctly executed`() = runTest { + fun `given parameters an no error when calling the task then it is correctly executed`() = runTest { val params = StartLiveLocationShareTask.Params( roomId = A_ROOM_ID, timeoutMillis = A_TIMEOUT @@ -63,7 +64,7 @@ internal class DefaultStartLiveLocationShareTaskTest { val result = defaultStartLiveLocationShareTask.execute(params) - result shouldBeEqualTo AN_EVENT_ID + result shouldBeEqualTo UpdateLiveLocationShareResult.Success(AN_EVENT_ID) val expectedBeaconContent = MessageBeaconInfoContent( timeout = params.timeoutMillis, isLive = true, diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultStopLiveLocationShareTaskTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultStopLiveLocationShareTaskTest.kt index 81a5742f90..78433d8b6e 100644 --- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultStopLiveLocationShareTaskTest.kt +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/session/room/location/DefaultStopLiveLocationShareTaskTest.kt @@ -19,11 +19,13 @@ package org.matrix.android.sdk.internal.session.room.location import io.mockk.unmockkAll import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest +import org.amshove.kluent.shouldBeEqualTo import org.junit.After import org.junit.Test import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.events.model.toContent +import org.matrix.android.sdk.api.session.room.location.UpdateLiveLocationShareResult import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent import org.matrix.android.sdk.internal.session.room.state.SendStateTask import org.matrix.android.sdk.test.fakes.FakeSendStateTask @@ -66,8 +68,9 @@ class DefaultStopLiveLocationShareTaskTest { fakeStateEventDataSource.givenGetStateEventReturns(currentStateEvent) fakeSendStateTask.givenExecuteRetryReturns(AN_EVENT_ID) - defaultStopLiveLocationShareTask.execute(params) + val result = defaultStopLiveLocationShareTask.execute(params) + result shouldBeEqualTo UpdateLiveLocationShareResult.Success(AN_EVENT_ID) val expectedBeaconContent = MessageBeaconInfoContent( timeout = A_TIMEOUT, isLive = false,