mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-28 03:48:37 +03:00
Adds Uri static mocking
This commit is contained in:
parent
9bd3254e41
commit
858923846d
3 changed files with 20 additions and 0 deletions
|
@ -16,8 +16,13 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.auth
|
package org.matrix.android.sdk.internal.auth
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import io.mockk.every
|
||||||
|
import io.mockk.mockk
|
||||||
|
import io.mockk.mockkStatic
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.test.runBlockingTest
|
import kotlinx.coroutines.test.runBlockingTest
|
||||||
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||||
|
@ -43,6 +48,12 @@ class DefaultSessionCreatorTest {
|
||||||
fakeSessionParamsCreator.instance,
|
fakeSessionParamsCreator.instance,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setup() {
|
||||||
|
mockkStatic(Uri::class)
|
||||||
|
every { Uri.parse(any()) } returns mockk()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `when createSession, then session created`() = runBlockingTest {
|
fun `when createSession, then session created`() = runBlockingTest {
|
||||||
val output = sessionCreator.createSession(credentials, homeServerConnectionConfig, LoginType.UNKNOWN)
|
val output = sessionCreator.createSession(credentials, homeServerConnectionConfig, LoginType.UNKNOWN)
|
||||||
|
|
|
@ -16,9 +16,12 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.test.fakes.internal.auth
|
package org.matrix.android.sdk.test.fakes.internal.auth
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
import io.mockk.coEvery
|
import io.mockk.coEvery
|
||||||
import io.mockk.coVerify
|
import io.mockk.coVerify
|
||||||
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
|
import io.mockk.mockkStatic
|
||||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||||
import org.matrix.android.sdk.internal.auth.SessionParamsCreator
|
import org.matrix.android.sdk.internal.auth.SessionParamsCreator
|
||||||
|
@ -30,6 +33,8 @@ internal class FakeSessionParamsCreator {
|
||||||
val instance: SessionParamsCreator = mockk()
|
val instance: SessionParamsCreator = mockk()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
mockkStatic(Uri::class)
|
||||||
|
every { Uri.parse(any()) } returns mockk()
|
||||||
coEvery { instance.create(any(), any(), any()) } returns sessionParams
|
coEvery { instance.create(any(), any(), any()) } returns sessionParams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.test.fakes.internal.auth.db.sessionparams
|
package org.matrix.android.sdk.test.fakes.internal.auth.db.sessionparams
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
import com.squareup.moshi.Moshi
|
import com.squareup.moshi.Moshi
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
|
import io.mockk.mockkStatic
|
||||||
import org.amshove.kluent.shouldBeEqualTo
|
import org.amshove.kluent.shouldBeEqualTo
|
||||||
import org.amshove.kluent.shouldBeNull
|
import org.amshove.kluent.shouldBeNull
|
||||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||||
|
@ -41,6 +43,8 @@ internal class FakeSessionParamsMapperMoshi {
|
||||||
val homeServerConnectionConfigAdapter = FakeHomeServerConnectionConfigJsonAdapter()
|
val homeServerConnectionConfigAdapter = FakeHomeServerConnectionConfigJsonAdapter()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
mockkStatic(Uri::class)
|
||||||
|
every { Uri.parse(any()) } returns mockk()
|
||||||
every { instance.adapter(Credentials::class.java) } returns credentialsJsonAdapter.instance
|
every { instance.adapter(Credentials::class.java) } returns credentialsJsonAdapter.instance
|
||||||
every { instance.adapter(HomeServerConnectionConfig::class.java) } returns homeServerConnectionConfigAdapter.instance
|
every { instance.adapter(HomeServerConnectionConfig::class.java) } returns homeServerConnectionConfigAdapter.instance
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue