Fix compilation error service test case

This commit is contained in:
Tomofumi Tanaka
2014-07-09 00:25:40 +09:00
parent c182cde14b
commit a2a2e22485
2 changed files with 10 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
package service
import scala.slick.session.Database
import model.simple._
import util.ControlUtil._
import java.sql.DriverManager
import org.apache.commons.io.FileUtils
@@ -9,15 +9,15 @@ import java.io.File
trait ServiceSpecBase {
def withTestDB[A](action: => A): A = {
def withTestDB[A](action: (Session) => A): A = {
util.FileUtil.withTmpDir(new File(FileUtils.getTempDirectory(), Random.alphanumeric.take(10).mkString)){ dir =>
val (url, user, pass) = (s"jdbc:h2:${dir}", "sa", "sa")
org.h2.Driver.load()
using(DriverManager.getConnection(url, user, pass)){ conn =>
servlet.AutoUpdate.versions.reverse.foreach(_.update(conn))
}
Database.forURL(url, user, pass).withSession {
action
Database.forURL(url, user, pass).withSession { session =>
action(session)
}
}
}