Add test on RustPushersService
This commit is contained in:
parent
297e97e7c9
commit
af9f02c5d7
2 changed files with 79 additions and 0 deletions
|
|
@ -17,6 +17,8 @@ import org.matrix.rustcomponents.sdk.NoPointer
|
||||||
import org.matrix.rustcomponents.sdk.NotificationClient
|
import org.matrix.rustcomponents.sdk.NotificationClient
|
||||||
import org.matrix.rustcomponents.sdk.NotificationProcessSetup
|
import org.matrix.rustcomponents.sdk.NotificationProcessSetup
|
||||||
import org.matrix.rustcomponents.sdk.NotificationSettings
|
import org.matrix.rustcomponents.sdk.NotificationSettings
|
||||||
|
import org.matrix.rustcomponents.sdk.PusherIdentifiers
|
||||||
|
import org.matrix.rustcomponents.sdk.PusherKind
|
||||||
import org.matrix.rustcomponents.sdk.RoomDirectorySearch
|
import org.matrix.rustcomponents.sdk.RoomDirectorySearch
|
||||||
import org.matrix.rustcomponents.sdk.Session
|
import org.matrix.rustcomponents.sdk.Session
|
||||||
import org.matrix.rustcomponents.sdk.SyncServiceBuilder
|
import org.matrix.rustcomponents.sdk.SyncServiceBuilder
|
||||||
|
|
@ -41,4 +43,14 @@ class FakeRustClient(
|
||||||
override suspend fun restoreSession(session: Session) = Unit
|
override suspend fun restoreSession(session: Session) = Unit
|
||||||
override fun syncService(): SyncServiceBuilder = FakeRustSyncServiceBuilder()
|
override fun syncService(): SyncServiceBuilder = FakeRustSyncServiceBuilder()
|
||||||
override fun roomDirectorySearch(): RoomDirectorySearch = FakeRoomDirectorySearch()
|
override fun roomDirectorySearch(): RoomDirectorySearch = FakeRoomDirectorySearch()
|
||||||
|
override suspend fun setPusher(
|
||||||
|
identifiers: PusherIdentifiers,
|
||||||
|
kind: PusherKind,
|
||||||
|
appDisplayName: String,
|
||||||
|
deviceDisplayName: String,
|
||||||
|
profileTag: String?,
|
||||||
|
lang: String,
|
||||||
|
) = Unit
|
||||||
|
|
||||||
|
override suspend fun deletePusher(identifiers: PusherIdentifiers) = Unit
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
* Please see LICENSE in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.libraries.matrix.impl.pushers
|
||||||
|
|
||||||
|
import io.element.android.libraries.matrix.api.pusher.SetHttpPusherData
|
||||||
|
import io.element.android.libraries.matrix.api.pusher.UnsetHttpPusherData
|
||||||
|
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustClient
|
||||||
|
import io.element.android.tests.testutils.testCoroutineDispatchers
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class RustPushersServiceTest {
|
||||||
|
@Test
|
||||||
|
fun `setPusher should invoke the client method`() = runTest {
|
||||||
|
val sut = RustPushersService(
|
||||||
|
client = FakeRustClient(),
|
||||||
|
dispatchers = testCoroutineDispatchers()
|
||||||
|
)
|
||||||
|
sut.setHttpPusher(
|
||||||
|
setHttpPusherData = aSetHttpPusherData()
|
||||||
|
).getOrThrow()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `unsetPusher should invoke the client method`() = runTest {
|
||||||
|
val sut = RustPushersService(
|
||||||
|
client = FakeRustClient(),
|
||||||
|
dispatchers = testCoroutineDispatchers()
|
||||||
|
)
|
||||||
|
sut.unsetHttpPusher(
|
||||||
|
unsetHttpPusherData = aUnsetHttpPusherData(),
|
||||||
|
).getOrThrow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun aSetHttpPusherData(
|
||||||
|
pushKey: String = "pushKey",
|
||||||
|
appId: String = "appId",
|
||||||
|
url: String = "url",
|
||||||
|
defaultPayload: String = "defaultPayload",
|
||||||
|
appDisplayName: String = "appDisplayName",
|
||||||
|
deviceDisplayName: String = "deviceDisplayName",
|
||||||
|
profileTag: String = "profileTag",
|
||||||
|
lang: String = "lang",
|
||||||
|
) = SetHttpPusherData(
|
||||||
|
pushKey = pushKey,
|
||||||
|
appId = appId,
|
||||||
|
url = url,
|
||||||
|
defaultPayload = defaultPayload,
|
||||||
|
appDisplayName = appDisplayName,
|
||||||
|
deviceDisplayName = deviceDisplayName,
|
||||||
|
profileTag = profileTag,
|
||||||
|
lang = lang
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun aUnsetHttpPusherData(
|
||||||
|
pushKey: String = "pushKey",
|
||||||
|
appId: String = "appId",
|
||||||
|
) = UnsetHttpPusherData(
|
||||||
|
pushKey = pushKey,
|
||||||
|
appId = appId,
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue