Created
March 4, 2015 15:46
-
-
Save songfei1983/ded744ed6b1a87a516df to your computer and use it in GitHub Desktop.
Evolution Unit Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import play.api.db.evolutions.Evolutions | |
import play.api.db.DBPlugin | |
import play.api.db.evolutions.InconsistentDatabase | |
import play.api.test.FakeApplication | |
import org.specs2.mutable._ | |
import org.specs2.runner._ | |
import org.junit.runner._ | |
/** | |
* Created by songfei on 15/03/05. | |
*/ | |
@RunWith(classOf[JUnitRunner]) | |
class EvolutionSpec extends Specification{ | |
val reversion = 1 | |
val additionalConfiguration = Map( | |
"db.default.driver" -> "org.h2.Driver", | |
"db.default.url" -> "jdbc:h2:mem:play", | |
"applyEvolutions.default" -> "false" | |
) | |
val fakeApplication: FakeApplication = FakeApplication(additionalConfiguration = additionalConfiguration, withoutPlugins = Seq("play.api.db.evolutions.EvolutionsPlugin")) | |
"Evolution" should { | |
"create tables " in { | |
val dbName = "default" | |
val dbApi = fakeApplication.plugin(classOf[DBPlugin]).get.api | |
try { | |
play.api.test.Helpers.running(fakeApplication) { | |
dbApi.withConnection(dbName) { c => | |
Evolutions.applyFor(dbName) | |
} | |
} | |
} catch { | |
case exp: InconsistentDatabase => println(exp.script + "¥nmessage: " + exp.error) | |
} | |
"a" must have size(1) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment