Fix: close all connections after each tests
This commit is contained in:
29
src/test/kotlin/eventDemo/externalServices/PostgresqlTest.kt
Normal file
29
src/test/kotlin/eventDemo/externalServices/PostgresqlTest.kt
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
20
src/test/kotlin/eventDemo/externalServices/RedisTest.kt
Normal file
20
src/test/kotlin/eventDemo/externalServices/RedisTest.kt
Normal 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"
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user