Skip to content

Instantly share code, notes, and snippets.

@marcospereira
Last active February 22, 2017 22:15
Show Gist options
  • Save marcospereira/fc47ab111f26b7594668864842866acc to your computer and use it in GitHub Desktop.
Save marcospereira/fc47ab111f26b7594668864842866acc to your computer and use it in GitHub Desktop.
trait ResetDbSpec extends PlaySpec with BeforeAndAfterAll {
private def withTestDatabase[T](block: Database => T) = {
Databases.withDatabase(
driver = "com.mysql.jdbc.Driver",
url = "jdbc:mysql://localhost/test",
name = "mydatabase",
config = Map(
"user" -> "test",
"password" -> "secret"
)
)(block)
}
override def beforeAll() = {
withTestDatabase { database =>
Evolutions.applyEvolutions(database)
}
}
override def afterAll() = {
withTestDatabase { database =>
Evolutions.cleanupEvolutions(database)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment