Adds Uri static mocking

This commit is contained in:
ericdecanini 2022-03-07 09:56:44 +01:00
parent 9bd3254e41
commit 858923846d
3 changed files with 20 additions and 0 deletions

View file

@ -16,8 +16,13 @@
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.test.runBlockingTest
import org.junit.Before
import org.junit.Test
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.internal.auth.login.LoginType
@ -43,6 +48,12 @@ class DefaultSessionCreatorTest {
fakeSessionParamsCreator.instance,
)
@Before
fun setup() {
mockkStatic(Uri::class)
every { Uri.parse(any()) } returns mockk()
}
@Test
fun `when createSession, then session created`() = runBlockingTest {
val output = sessionCreator.createSession(credentials, homeServerConnectionConfig, LoginType.UNKNOWN)

View file

@ -16,9 +16,12 @@
package org.matrix.android.sdk.test.fakes.internal.auth
import android.net.Uri
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
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.HomeServerConnectionConfig
import org.matrix.android.sdk.internal.auth.SessionParamsCreator
@ -30,6 +33,8 @@ internal class FakeSessionParamsCreator {
val instance: SessionParamsCreator = mockk()
init {
mockkStatic(Uri::class)
every { Uri.parse(any()) } returns mockk()
coEvery { instance.create(any(), any(), any()) } returns sessionParams
}

View file

@ -16,9 +16,11 @@
package org.matrix.android.sdk.test.fakes.internal.auth.db.sessionparams
import android.net.Uri
import com.squareup.moshi.Moshi
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldBeNull
import org.matrix.android.sdk.api.auth.data.Credentials
@ -41,6 +43,8 @@ internal class FakeSessionParamsMapperMoshi {
val homeServerConnectionConfigAdapter = FakeHomeServerConnectionConfigJsonAdapter()
init {
mockkStatic(Uri::class)
every { Uri.parse(any()) } returns mockk()
every { instance.adapter(Credentials::class.java) } returns credentialsJsonAdapter.instance
every { instance.adapter(HomeServerConnectionConfig::class.java) } returns homeServerConnectionConfigAdapter.instance
}