playframework 2.4 - (Play 2.4.2, Play Slick 1.0.0) How do I apply database Evolutions to a Slick managed database within a test? -


i write database integration tests against play slick managed database , apply , unapply evolutions using helper methods described in play documentation namely, evolutions.applyevolutions(database) , evolutions.cleanupevolutions(database). these require play.api.db.database instance not possible hold of can see. jdbc library conflicts play-slick how database instance slick? use following slick database def running slick queries:

val dbconfig = databaseconfigprovider.get[jdbcprofile]("my-test-db")(fakeapplication())   import dbconfig.driver.api._ val db = dbconfig.db 

thanks,

leanne

here how dow guice:

i inject guice:

lazy val appbuilder = new guiceapplicationbuilder()  lazy val injector = appbuilder.injector()  lazy val databaseapi = injector.instanceof[dbapi] //here important line 

(you have import play.api.db.dbapi.)

and in tests, following (actually use other database tests):

override def beforeall() = {   evolutions.applyevolutions(databaseapi.database("default")) }  override def afterall() = {   evolutions.cleanupevolutions(databaseapi.database("default")) } 

(i'm using scalatest same thing other testing framework.)


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -