test: Mock searchSync to prevent crash in ComposeActivityTest (#404)
Without the mock the code-under-test was getting a null value where none should have been possible, and crashing.
This commit is contained in:
parent
ce21b3b9f8
commit
7116c8e0c3
|
@ -29,6 +29,7 @@ import app.pachli.core.navigation.ComposeActivityIntent.ComposeOptions
|
||||||
import app.pachli.core.network.model.Account
|
import app.pachli.core.network.model.Account
|
||||||
import app.pachli.core.network.model.InstanceConfiguration
|
import app.pachli.core.network.model.InstanceConfiguration
|
||||||
import app.pachli.core.network.model.InstanceV1
|
import app.pachli.core.network.model.InstanceV1
|
||||||
|
import app.pachli.core.network.model.SearchResult
|
||||||
import app.pachli.core.network.model.StatusConfiguration
|
import app.pachli.core.network.model.StatusConfiguration
|
||||||
import app.pachli.core.network.retrofit.MastodonApi
|
import app.pachli.core.network.retrofit.MastodonApi
|
||||||
import app.pachli.core.testing.rules.lazyActivityScenarioRule
|
import app.pachli.core.testing.rules.lazyActivityScenarioRule
|
||||||
|
@ -47,6 +48,8 @@ import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
import org.mockito.kotlin.any
|
||||||
|
import org.mockito.kotlin.anyOrNull
|
||||||
import org.mockito.kotlin.doAnswer
|
import org.mockito.kotlin.doAnswer
|
||||||
import org.mockito.kotlin.doReturn
|
import org.mockito.kotlin.doReturn
|
||||||
import org.mockito.kotlin.reset
|
import org.mockito.kotlin.reset
|
||||||
|
@ -96,6 +99,9 @@ class ComposeActivityTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onBlocking { searchSync(any(), anyOrNull(), anyOrNull(), anyOrNull(), anyOrNull(), anyOrNull()) } doReturn NetworkResult.success(
|
||||||
|
SearchResult(emptyList(), emptyList(), emptyList()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
accountManager.addAccount(
|
accountManager.addAccount(
|
||||||
|
|
Loading…
Reference in New Issue