MicroUtils/startup/launcher/src/jvmTest/kotlin/StartupLaunchingTests.kt

47 lines
1.4 KiB
Kotlin
Raw Normal View History

import dev.inmo.micro_utils.coroutines.launchSynchronously
import dev.inmo.micro_utils.startup.launcher.Config
import dev.inmo.micro_utils.startup.launcher.HelloWorldPlugin
import dev.inmo.micro_utils.startup.launcher.defaultJson
import dev.inmo.micro_utils.startup.launcher.start
import kotlinx.coroutines.launch
2022-12-07 04:50:51 +00:00
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.json.jsonObject
2022-12-07 04:50:51 +00:00
import org.koin.core.context.GlobalContext
import kotlin.test.BeforeTest
import kotlin.test.Test
class StartupLaunchingTests {
2022-12-07 04:50:51 +00:00
@BeforeTest
fun resetGlobalKoinContext() {
kotlin.runCatching { GlobalContext.stopKoin() }
}
2022-12-07 05:39:45 +00:00
@Test(timeout = 60000L)
fun CheckThatEmptyPluginsListLeadsToEndOfMain() {
val emptyJson = defaultJson.encodeToJsonElement(
Config.serializer(),
Config(emptyList())
).jsonObject
2022-12-07 04:50:51 +00:00
runTest {
val job = launch {
start(emptyJson)
}
job.join()
}
}
2022-12-07 05:39:45 +00:00
@Test(timeout = 60000L)
fun CheckThatHelloWorldPluginsListLeadsToEndOfMain() {
val emptyJson = defaultJson.encodeToJsonElement(
Config.serializer(),
Config(listOf(HelloWorldPlugin))
).jsonObject
2022-12-07 04:50:51 +00:00
runTest {
val job = launch {
start(emptyJson)
}
job.join()
}
}
}