2022-12-06 06:38:24 +00:00
|
|
|
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
|
2022-12-06 06:38:24 +00:00
|
|
|
import kotlinx.serialization.json.jsonObject
|
2022-12-07 04:50:51 +00:00
|
|
|
import kotlin.test.BeforeTest
|
2022-12-06 06:38:24 +00:00
|
|
|
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
|
2022-12-06 06:38:24 +00:00
|
|
|
fun CheckThatEmptyPluginsListLeadsToEndOfMain() {
|
|
|
|
val emptyJson = defaultJson.encodeToJsonElement(
|
|
|
|
Config.serializer(),
|
|
|
|
Config(emptyList())
|
|
|
|
).jsonObject
|
|
|
|
|
2022-12-07 04:50:51 +00:00
|
|
|
runTest {
|
2022-12-06 06:38:24 +00:00
|
|
|
val job = launch {
|
|
|
|
start(emptyJson)
|
|
|
|
}
|
|
|
|
job.join()
|
|
|
|
}
|
|
|
|
}
|
2022-12-15 04:26:31 +00:00
|
|
|
@Test
|
2022-12-06 06:38:24 +00:00
|
|
|
fun CheckThatHelloWorldPluginsListLeadsToEndOfMain() {
|
|
|
|
val emptyJson = defaultJson.encodeToJsonElement(
|
|
|
|
Config.serializer(),
|
|
|
|
Config(listOf(HelloWorldPlugin))
|
|
|
|
).jsonObject
|
|
|
|
|
2022-12-07 04:50:51 +00:00
|
|
|
runTest {
|
2022-12-06 06:38:24 +00:00
|
|
|
val job = launch {
|
|
|
|
start(emptyJson)
|
|
|
|
}
|
|
|
|
job.join()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|