05/14/2022, 2:21 PM
Hello! I'm trying to implement web service usig Ktor and Exposed. The server itself works fine, but application tests are failing without an active database connection.
class ApplicationTest {
    fun testRoot() = testApplication {
        val response = client.get("/")
        assertEquals(HttpStatusCode.OK, response.status)
basically this sample test is failing because it seems like
tries to init hikari conn pool. If I run database everything is ok. Can I substitute this w/ in memory database somehow? Or better yet, drop the DB connection altogether and use service layer mock? Sorry if the question is dumb, I have no experience with JVM ecosystem, would be glad to get any suggestions.


05/14/2022, 4:11 PM
Yeah obviously - if your app connects to the DB and you dont have a DB it wont work You need to have the code read some parameter that tells it whether it should init a real db vs an in memory db or whatever Dependency injection is what you are looking for
:tnx: 1
👍 1