|
| 1 | +/* |
| 2 | + * Copyright 2024 New Vector Ltd. |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: AGPL-3.0-only |
| 5 | + * Please see LICENSE in the repository root for full details. |
| 6 | + */ |
| 7 | + |
| 8 | +package io.element.android.libraries.matrix.impl.pushers |
| 9 | + |
| 10 | +import io.element.android.libraries.matrix.api.pusher.SetHttpPusherData |
| 11 | +import io.element.android.libraries.matrix.api.pusher.UnsetHttpPusherData |
| 12 | +import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustClient |
| 13 | +import io.element.android.tests.testutils.testCoroutineDispatchers |
| 14 | +import kotlinx.coroutines.test.runTest |
| 15 | +import org.junit.Test |
| 16 | + |
| 17 | +class RustPushersServiceTest { |
| 18 | + @Test |
| 19 | + fun `setPusher should invoke the client method`() = runTest { |
| 20 | + val sut = RustPushersService( |
| 21 | + client = FakeRustClient(), |
| 22 | + dispatchers = testCoroutineDispatchers() |
| 23 | + ) |
| 24 | + sut.setHttpPusher( |
| 25 | + setHttpPusherData = aSetHttpPusherData() |
| 26 | + ).getOrThrow() |
| 27 | + } |
| 28 | + |
| 29 | + @Test |
| 30 | + fun `unsetPusher should invoke the client method`() = runTest { |
| 31 | + val sut = RustPushersService( |
| 32 | + client = FakeRustClient(), |
| 33 | + dispatchers = testCoroutineDispatchers() |
| 34 | + ) |
| 35 | + sut.unsetHttpPusher( |
| 36 | + unsetHttpPusherData = aUnsetHttpPusherData(), |
| 37 | + ).getOrThrow() |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +private fun aSetHttpPusherData( |
| 42 | + pushKey: String = "pushKey", |
| 43 | + appId: String = "appId", |
| 44 | + url: String = "url", |
| 45 | + defaultPayload: String = "defaultPayload", |
| 46 | + appDisplayName: String = "appDisplayName", |
| 47 | + deviceDisplayName: String = "deviceDisplayName", |
| 48 | + profileTag: String = "profileTag", |
| 49 | + lang: String = "lang", |
| 50 | +) = SetHttpPusherData( |
| 51 | + pushKey = pushKey, |
| 52 | + appId = appId, |
| 53 | + url = url, |
| 54 | + defaultPayload = defaultPayload, |
| 55 | + appDisplayName = appDisplayName, |
| 56 | + deviceDisplayName = deviceDisplayName, |
| 57 | + profileTag = profileTag, |
| 58 | + lang = lang |
| 59 | +) |
| 60 | + |
| 61 | +private fun aUnsetHttpPusherData( |
| 62 | + pushKey: String = "pushKey", |
| 63 | + appId: String = "appId", |
| 64 | +) = UnsetHttpPusherData( |
| 65 | + pushKey = pushKey, |
| 66 | + appId = appId, |
| 67 | +) |
0 commit comments