Testing - Using Postgres in Prod, but H2 in Test

102 views
Skip to first unread message

Kevin Meredith

unread,
Oct 18, 2015, 9:36:57 PM10/18/15
to Slick / ScalaQuery
I'm trying to set up in-memory integration tests for my Slick 3 DB services.

I saw https://www.typesafe.com/activator/template/slick-testkit-example-3.0. However, I'm accessing Postgres in my prod code, but H2 in test.

Are there any examples on how to perform such testing? 

Mirco Dotta

unread,
Oct 19, 2015, 5:25:43 AM10/19/15
to scala...@googlegroups.com
Hi Kevin,

To abstract over the database you can use different configuration files for test and prod. Use Database.forConfig to get back a DatabaseConfig, which holds a database and a driver. Then, it will be usual Slick code from there.

Cheers,
Mirco
----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

--

---
You received this message because you are subscribed to the Google Groups "Slick / ScalaQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaquery+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaquery/3dfa5c55-cd27-478a-b7c4-746d4237f483%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

lavia kaménémwen

unread,
Dec 6, 2015, 8:16:32 PM12/6/15
to Slick / ScalaQuery
Hello,

Mirco's answer is logical, but just like you, I have trouble to figure out the pattern to inject Postgres for production and "override" it with h2 for test ... have you found out? Do you have an example to help me?

Thanks
Reply all
Reply to author
Forward
0 new messages