I would like to test a class that injects a DatabaseConfigProvider. I would like to use inMemory database instead of PostgreSQL during the tests. The class looks like this one (I'm using Slick 3):
class myClass @Inject() (protected val dbConfigProvider: DatabaseConfigProvider)
extends HasDatabaseConfigProvider[MyPostgresDriver] {
Today without using an inMemory database, to test my class, I inject dbConfProvider, defined as:
lazy val appBuilder = new GuiceApplicationBuilder()
.in(Mode.Test)
.configure(Map("akka.remote.netty.tcp.port" -> 0))
lazy val injector = appBuilder.injector()
lazy val dbConfProvider = injector.instanceOf[DatabaseConfigProvider]
and I get an instance of the class like this:
val myClass = new MyClass(dbConfProvider)
How can I inject an inMemory database instead?
Aucun commentaire:
Enregistrer un commentaire