Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ crossScalaVersions := List("2.12.20", "2.13.17", "3.3.7")

libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.6.1",
"com.dimafeng" %% "testcontainers-scala" % "0.43.0" % "test",
"org.testcontainers" % "mysql" % "1.21.3" % "test",
"org.testcontainers" % "testcontainers-mysql" % "2.0.1" % "test",
"com.mysql" % "mysql-connector-j" % "9.4.0" % "test",
"org.scalatest" %% "scalatest-funsuite" % "3.2.19" % "test",
"com.h2database" % "h2" % "1.4.192" % "test",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.github.takezoe.slick.blocking

import com.dimafeng.testcontainers.Container
import com.dimafeng.testcontainers.ForAllTestContainer
import com.dimafeng.testcontainers.JdbcDatabaseContainer
import com.dimafeng.testcontainers.MySQLContainer
import org.scalatest.BeforeAndAfterAll
import org.scalatest.funsuite.AnyFunSuite
import org.testcontainers.containers.JdbcDatabaseContainer
import org.testcontainers.mysql.MySQLContainer
import org.testcontainers.utility.DockerImageName
import slick.jdbc.JdbcBackend
import slick.jdbc.meta.MTable
import scala.concurrent.Await
import scala.concurrent.ExecutionContext
Expand All @@ -24,21 +22,31 @@ class SlickBlockingAPISpecMySQL56 extends SlickBlockingAPISpecMySQL("5.6")

abstract class SlickBlockingAPISpecMySQL(mysqlVersion: String)
extends SlickBlockingAPISpecTestContainer(
MySQLContainer(mysqlImageVersion = DockerImageName.parse("mysql:" + mysqlVersion)),
new MySQLContainer(DockerImageName.parse("mysql:" + mysqlVersion)),
BlockingMySQLDriver
)

abstract class SlickBlockingAPISpecTestContainer(
override val container: JdbcDatabaseContainer & Container,
container: JdbcDatabaseContainer[?],
profile: BlockingJdbcProfile
) extends SlickBlockingAPISpec(profile)
with ForAllTestContainer {
with BeforeAndAfterAll {

override lazy val db = Tables.profile.blockingApi.Database.forURL(
url = container.jdbcUrl,
user = container.username,
password = container.password,
driver = container.driverClassName
override def beforeAll(): Unit = {
super.beforeAll()
container.start()
}

override def afterAll(): Unit = {
super.afterAll()
container.stop()
}

lazy val db = Tables.profile.blockingApi.Database.forURL(
url = container.getJdbcUrl,
user = container.getUsername,
password = container.getPassword,
driver = container.getDriverClassName
)

}
Expand Down