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

45 lines
1.2 KiB
Kotlin
Raw Normal View History

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 kotlin.test.BeforeTest
import kotlin.test.Test
class StartupLaunchingTests {
2022-12-07 04:50:51 +00:00
@BeforeTest
fun resetGlobalKoinContext() {
2022-12-15 04:26:31 +00:00
runCatching { stopKoin() }
2022-12-07 04:50:51 +00:00
}
2022-12-15 04:26:31 +00:00
@Test
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-15 04:26:31 +00:00
@Test
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()
}
}
}