Fixing unit tests
This commit is contained in:
parent
6c0b7f7b43
commit
3e05431e6f
@ -27,6 +27,7 @@ import kotlinx.coroutines.test.runTest
|
|||||||
import org.amshove.kluent.shouldBeEqualTo
|
import org.amshove.kluent.shouldBeEqualTo
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Test
|
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.session.room.model.livelocation.LiveLocationShareAggregatedSummary
|
||||||
import org.matrix.android.sdk.api.util.Cancelable
|
import org.matrix.android.sdk.api.util.Cancelable
|
||||||
import org.matrix.android.sdk.internal.database.mapper.LiveLocationShareAggregatedSummaryMapper
|
import org.matrix.android.sdk.internal.database.mapper.LiveLocationShareAggregatedSummaryMapper
|
||||||
@ -119,11 +120,11 @@ internal class DefaultLocationSharingServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `live location share can be started with a given timeout`() = runTest {
|
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(
|
val expectedParams = StartLiveLocationShareTask.Params(
|
||||||
roomId = A_ROOM_ID,
|
roomId = A_ROOM_ID,
|
||||||
timeoutMillis = A_TIMEOUT
|
timeoutMillis = A_TIMEOUT
|
||||||
@ -133,10 +134,11 @@ internal class DefaultLocationSharingServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `live location share can be stopped`() = runTest {
|
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(
|
val expectedParams = StopLiveLocationShareTask.Params(
|
||||||
roomId = A_ROOM_ID
|
roomId = A_ROOM_ID
|
||||||
)
|
)
|
||||||
|
@ -24,6 +24,7 @@ import org.junit.After
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
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.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.api.session.room.model.message.MessageBeaconInfoContent
|
||||||
import org.matrix.android.sdk.internal.session.room.state.SendStateTask
|
import org.matrix.android.sdk.internal.session.room.state.SendStateTask
|
||||||
import org.matrix.android.sdk.test.fakes.FakeClock
|
import org.matrix.android.sdk.test.fakes.FakeClock
|
||||||
@ -53,7 +54,7 @@ internal class DefaultStartLiveLocationShareTaskTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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(
|
val params = StartLiveLocationShareTask.Params(
|
||||||
roomId = A_ROOM_ID,
|
roomId = A_ROOM_ID,
|
||||||
timeoutMillis = A_TIMEOUT
|
timeoutMillis = A_TIMEOUT
|
||||||
@ -63,7 +64,7 @@ internal class DefaultStartLiveLocationShareTaskTest {
|
|||||||
|
|
||||||
val result = defaultStartLiveLocationShareTask.execute(params)
|
val result = defaultStartLiveLocationShareTask.execute(params)
|
||||||
|
|
||||||
result shouldBeEqualTo AN_EVENT_ID
|
result shouldBeEqualTo UpdateLiveLocationShareResult.Success(AN_EVENT_ID)
|
||||||
val expectedBeaconContent = MessageBeaconInfoContent(
|
val expectedBeaconContent = MessageBeaconInfoContent(
|
||||||
timeout = params.timeoutMillis,
|
timeout = params.timeoutMillis,
|
||||||
isLive = true,
|
isLive = true,
|
||||||
|
@ -19,11 +19,13 @@ package org.matrix.android.sdk.internal.session.room.location
|
|||||||
import io.mockk.unmockkAll
|
import io.mockk.unmockkAll
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.amshove.kluent.shouldBeEqualTo
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
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.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
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.api.session.room.model.message.MessageBeaconInfoContent
|
||||||
import org.matrix.android.sdk.internal.session.room.state.SendStateTask
|
import org.matrix.android.sdk.internal.session.room.state.SendStateTask
|
||||||
import org.matrix.android.sdk.test.fakes.FakeSendStateTask
|
import org.matrix.android.sdk.test.fakes.FakeSendStateTask
|
||||||
@ -66,8 +68,9 @@ class DefaultStopLiveLocationShareTaskTest {
|
|||||||
fakeStateEventDataSource.givenGetStateEventReturns(currentStateEvent)
|
fakeStateEventDataSource.givenGetStateEventReturns(currentStateEvent)
|
||||||
fakeSendStateTask.givenExecuteRetryReturns(AN_EVENT_ID)
|
fakeSendStateTask.givenExecuteRetryReturns(AN_EVENT_ID)
|
||||||
|
|
||||||
defaultStopLiveLocationShareTask.execute(params)
|
val result = defaultStopLiveLocationShareTask.execute(params)
|
||||||
|
|
||||||
|
result shouldBeEqualTo UpdateLiveLocationShareResult.Success(AN_EVENT_ID)
|
||||||
val expectedBeaconContent = MessageBeaconInfoContent(
|
val expectedBeaconContent = MessageBeaconInfoContent(
|
||||||
timeout = A_TIMEOUT,
|
timeout = A_TIMEOUT,
|
||||||
isLive = false,
|
isLive = false,
|
||||||
|
Loading…
Reference in New Issue
Block a user