chore: run CI test in docker
Tests / build (push) Successful in 7m13s
Tests / test (push) Failing after 9m19s
Tests / lint (push) Successful in 13m33s

This commit is contained in:
2026-08-04 20:28:49 +02:00
parent e262f35b27
commit b60e4aa457
10 changed files with 100 additions and 90 deletions
+3 -3
View File
@@ -13,12 +13,12 @@ jwt {
}
redis {
url = "redis://localhost:6379"
url = "redis://redis:6379"
url = ${?REDIS_URL}
}
postgresql {
url = "jdbc:postgresql://localhost:5432/event-demo"
url = "jdbc:postgresql://postgresql/event-demo"
url = ${?POSTGRESQL_URL}
username = "event-demo"
@@ -29,7 +29,7 @@ postgresql {
}
rabbitmq {
url = "localhost"
url = "rabbitmq"
url = ${?RABBITMQ_URL}
port = "5672"
+21 -25
View File
@@ -2,6 +2,7 @@ package eventDemo.libs.bus
import com.rabbitmq.client.ConnectionFactory
import eventDemo.testHelpers.spyPing
import eventDemo.testHelpers.testKoinApplicationWithConfig
import io.kotest.core.spec.style.FunSpec
import io.kotest.datatest.withData
import io.kotest.matchers.string.shouldStartWith
@@ -15,33 +16,28 @@ private data class ObjTest(
class BusTest :
FunSpec({
context("Pub/sub") {
val factory =
ConnectionFactory().apply {
host = "localhost"
port = 5672
username = "event-demo"
password = "changeit"
}
val list: Map<String, Bus<ObjTest>> =
mapOf(
BusInMemory::class.java.simpleName to BusInMemory(),
BusInRabbitMQ::class.java.simpleName to
BusInRabbitMQ(
factory,
"testExchange",
{ it.value },
{ ObjTest(it) },
),
)
testKoinApplicationWithConfig {
val list: Map<String, Bus<ObjTest>> =
mapOf(
BusInMemory::class.java.simpleName to BusInMemory(),
BusInRabbitMQ::class.java.simpleName to
BusInRabbitMQ(
get<ConnectionFactory>(),
"testExchange",
{ it.value },
{ ObjTest(it) },
),
)
withData(list) { bus ->
spyPing(exactly = 2, duration = 1.seconds) { ping ->
bus.subscribe { obj ->
ping()
obj.value shouldStartWith "testMessage"
withData(list) { bus ->
spyPing(exactly = 2, duration = 1.seconds) { ping ->
bus.subscribe { obj ->
ping()
obj.value shouldStartWith "testMessage"
}
bus.publish(ObjTest("testMessage${Random.nextInt()}"))
bus.publish(ObjTest("testMessage${Random.nextInt()}"))
}
bus.publish(ObjTest("testMessage${Random.nextInt()}"))
bus.publish(ObjTest("testMessage${Random.nextInt()}"))
}
}
}
@@ -15,10 +15,13 @@ import org.koin.core.module.KoinApplicationDslMarker
import org.koin.dsl.koinApplication
import org.koin.ktor.ext.getKoin
const val CONFIG_FILE_NAME = "application.conf"
@KoinApplicationDslMarker
suspend fun <T> testKoinApplicationWithConfig(block: suspend Koin.() -> T): T =
koinApplication { modules(appKoinModule(ApplicationConfig("application.conf").configuration)) }
.koin
koinApplication {
modules(appKoinModule(ApplicationConfig(CONFIG_FILE_NAME).configuration))
}.koin
.run {
cleanDataTest()
configureProjectionListener()
@@ -34,7 +37,7 @@ fun testApplicationWithConfig(
) {
val logger = KotlinLogging.logger {}
testApplication {
val conf = ApplicationConfig("application.conf")
val conf = ApplicationConfig(CONFIG_FILE_NAME)
environment {
config = conf
}