doyaaaaaaken
06/05/2022, 6:12 AMDatabase.connect()
) on the beginning of Ktor’s booting process (the first line of Application.module()
).
When I use Ktor v2, the testApplication
method creates a Ktor server application on each test method.
So, errors happens which says too many db clients
.
How do I solve it? Does anyone know this? 🙏hfhbd
06/05/2022, 1:52 PMdoyaaaaaaken
06/06/2022, 6:16 AMJPilson Sumbo
03/31/2023, 12:53 AMdoyaaaaaaken
03/31/2023, 1:13 AMDbConnector.connect()
//This process is executed when application stops
environment.monitor.subscribe(ApplicationStopped) {
DbConnector.close()
}
JPilson Sumbo
03/31/2023, 7:08 AMdoyaaaaaaken
03/31/2023, 7:16 AMabstract class DbAccessTest {
fun <T> withDbAccess(proc: () -> T): T {
return transaction {
val result = proc()
rollback()
result
}
}
companion object {
init {
//connection procesure
//...
Database.connect(ds)
}
}
}
JPilson Sumbo
03/31/2023, 8:10 AM