Fix: close all connections after each tests

This commit is contained in:
2025-04-10 22:44:26 +02:00
parent aa9dac74e8
commit 0aa13b9299
14 changed files with 307 additions and 226 deletions

View File

@@ -0,0 +1,29 @@
package eventDemo.externalServices
import eventDemo.testKoinApplicationWithConfig
import io.kotest.core.NamedTag
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.equals.shouldBeEqual
import javax.sql.DataSource
class PostgresqlTest :
FunSpec({
tags(NamedTag("postgresql"))
test("test connection with postgresql") {
testKoinApplicationWithConfig {
val datasource by inject<DataSource>()
datasource.connection.use { connection ->
connection
.prepareStatement(
"""
select 1;
""".trimIndent(),
).execute()
.let {
it shouldBeEqual true
}
}
}
}
})

View File

@@ -0,0 +1,20 @@
package eventDemo.externalServices
import io.kotest.core.NamedTag
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.equals.shouldBeEqual
import redis.clients.jedis.JedisPooled
private val redisUrl = "redis://localhost:6379"
class RedisTest :
FunSpec({
tags(NamedTag("redis"))
xtest("test connection with jedis") {
JedisPooled(redisUrl).also {
it.set("test", "test")
it.get("test") shouldBeEqual "test"
}
}
})