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

46 lines
1.3 KiB
Kotlin
Raw Normal View History

import dev.inmo.micro_utils.startup.launcher.Config
import dev.inmo.micro_utils.startup.launcher.HelloWorldPlugin
2022-12-25 04:26:44 +00:00
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin
import dev.inmo.micro_utils.startup.launcher.defaultJson
import kotlinx.coroutines.launch
2022-12-07 04:50:51 +00:00
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.json.jsonObject
import org.koin.core.context.stopKoin
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 {
2022-12-25 04:26:44 +00:00
StartLauncherPlugin.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 {
2022-12-25 04:26:44 +00:00
StartLauncherPlugin.start(emptyJson)
}
job.join()
}
}
}