Skip to content

Commit

Permalink
Add a test for applying migrations after the database is deleted.
Browse files Browse the repository at this point in the history
Related to #22.
  • Loading branch information
lastland committed Aug 9, 2016
1 parent 21daf5c commit 5e0d011
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion migrations/slick/src/test/scala/UnitTests/CommandsTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,43 @@ ${"\t"}CommandTests.profile.api.queryInsertActionExtensionMethods[CommandTests.t

class H2CommandTests extends CommandTests with H2ConfigFile

class SQLiteCommandTests extends CommandTests with SQLiteConfigFile
class SQLiteCommandTests extends CommandTests with SQLiteConfigFile {
import profile.api._

class TestSlickMigrationManager extends SlickMigrationManager
with SlickMigrationCommands with SlickCodegen {
override lazy val dbConfig = theDBConfig
override lazy val config = theConfig
migrations = MigrationSeq.example
}

"migrateOp" should "apply the migrations if the db is deleted after successful migrations" in {
var m = new TestSlickMigrationManager
try {
m.init
m.migrateOp(Seq())
} finally {
m.db.close()
}
val dbFile = new java.io.File(dbUrl.substring("jdbc:sqlite:".length))
dbFile.delete()
m = new TestSlickMigrationManager
try {
m.init
m.migrateOp(Seq())
val f = m.db.run {
UsersV3.result
} map { users =>
for (user <- users) yield (user.id, user.first, user.last)
}
val us = Await.result(f, waitTime)
assert(us.toSet === Set((1, "Chris", "Vogt"), (2, "Yao", "Li")))
} finally {
m.reset
m.db.close()
}
}
}

class MySQLCommandTests extends CommandTests with MySQLConfigFile {
import profile.api._
Expand Down

0 comments on commit 5e0d011

Please sign in to comment.