Hello,
I have a common test that needs to run on different targets: Android, iOS and Native.
Android and Native work just fine, but with iosX64Test I am getting a timeout. Running the function on the emulator works.
I am getting the following error
Invalid connection: com.apple.coresymbolicationd
kotlinx.coroutines.test.UncompletedCoroutinesError: After waiting for 60000 ms, the test coroutine is not completing
Here a bigger picture
internal class AdsSdkConfigurationDataSourceTest : KoinTest {
private val adsSdkConfigurationDataSource by inject<AdsSdkConfigurationDataSource>()
@BeforeTest
fun setUp() {
Dispatchers.setMain(StandardTestDispatcher())
startKoin {
modules(
HttpClientModule().module,
module {
singleOf(::PublisherConfigurationEndpointV1) bind PublisherConfigurationEndpoint::class
singleOf(::AdsSdkConfigurationDataSource)
}
)
}
}
@Test
fun `returns expected projectId`() = runTest {
val content = RequestBody(
platform = "android",
sdkVersion = "4.1.3",
gameId = GameId("14851"),
)
val response = adsSdkConfigurationDataSource.getPublisherConfiguration(content)
assertTrue(response.enabled)
}
}
Where getPublisherConfiguration
looks like
@Single
class AdsSdkConfigurationDataSource(
private val httpClient: HttpClient,
private val publisherConfigurationEndpoint: PublisherConfigurationEndpoint
) {
suspend fun getPublisherConfiguration(requestBody: RequestBody) =
httpClient.post(publisherConfigurationEndpoint.configuration(requestBody.gameId.value)) {
contentType(ContentType.Application.Json)
setBody(requestBody)
}.body<PublisherConfigurationApiModel>()
}
I use Ktor 2.0.1 and Kotlin 1.6.20