https://kotlinlang.org logo
#exposed
Title
# exposed
s

SerVB

04/10/2020, 8:34 PM
Could anybody please advise a guide how to test my app which uses postgres DB? I think mocking Exposed is quite tricky, so maybe I should just somehow create a DB for every test case. but anyway I don't know how. Of course I can declare something like "before every test start docker" and "after every test stop docker" via
ProcessBuilder
, but it seems too rough... Is there an in-memory DB that I can create in JVM and with which Exposed can work?
Should I use testcontainers?
h

hichem fazai

04/10/2020, 10:27 PM
There is a library allowing you to make unit test with Postgres without requiring to install and set up a database cluster. https://github.com/opentable/otj-pg-embedded
😆 1
it's already used by Exposed
🙏 1
g

Gunslingor

04/11/2020, 5:29 PM
I created a UserData Class, then a list variable with a bunch of those in it called testUsers. Then I just created tests that insert, select, delete, insert, etc in the appropriate order with a beginning setup operation. I have a gradle tasks that can kick of the DB build too, tables only... but the testing wasn't tough
3 Views