Skip to content

Commit a7db450

Browse files
committed
Update testcontainers
1 parent 79ee72c commit a7db450

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

build.sbt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ lazy val core = (project in file("core")).settings(
5252
"org.scalikejdbc" %% "scalikejdbc-joda-time" % scalikejdbcVersion % "test",
5353
"com.github.jasync-sql" % "jasync-postgresql" % jasyncVersion % "provided",
5454
"com.github.jasync-sql" % "jasync-mysql" % jasyncVersion % "provided",
55-
"com.dimafeng" %% "testcontainers-scala" % "0.43.0" % "test",
56-
"org.testcontainers" % "mysql" % "1.21.3" % "test",
57-
"org.testcontainers" % "postgresql" % "1.21.3" % "test",
55+
"org.testcontainers" % "testcontainers-mysql" % "2.0.1" % "test",
56+
"org.testcontainers" % "testcontainers-postgresql" % "2.0.1" % "test",
5857
"org.postgresql" % "postgresql" % postgresqlVersion % "test",
5958
mysqlConnectorJ,
6059
"ch.qos.logback" % "logback-classic" % "1.2.+" % "test"

core/src/test/scala/programmerlist/ExampleSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class ExampleSpec
8181
AsyncConnectionPool.add(
8282
name,
8383
postgresJdbcUrl,
84-
postgres.username,
85-
postgres.password,
84+
postgres.getUsername,
85+
postgres.getPassword,
8686
AsyncConnectionPoolSettings(maxPoolSize = MaxPoolSize)
8787
)
8888

core/src/test/scala/unit/DBSettings.scala

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
11
package unit
22

33
import scalikejdbc._
4-
import async.{ AsyncConnectionPoolSettings, _ }
5-
import com.dimafeng.testcontainers.{
6-
Container,
7-
ForAllTestContainer,
8-
MultipleContainers,
9-
MySQLContainer,
10-
PostgreSQLContainer
11-
}
4+
import scalikejdbc.async._
125
import org.testcontainers.utility.DockerImageName
13-
import org.scalatest.Suite
6+
import org.scalatest.{ BeforeAndAfterAll, Suite }
7+
import org.testcontainers.mysql.MySQLContainer
8+
import org.testcontainers.postgresql.PostgreSQLContainer
149

15-
trait DBSettings extends ForAllTestContainer { self: Suite =>
10+
trait DBSettings extends BeforeAndAfterAll { self: Suite =>
1611
protected[this] def mysqlVersion: String = sys.props("mysql_version")
1712
protected[this] final val mysql =
18-
MySQLContainer(mysqlImageVersion =
13+
new MySQLContainer(
1914
DockerImageName.parse(s"mysql:${mysqlVersion}")
2015
)
21-
protected[this] final val postgres = PostgreSQLContainer(
16+
protected[this] final val postgres = new PostgreSQLContainer(
2217
DockerImageName.parse("postgres:11.4")
2318
)
24-
override val container: Container = MultipleContainers(mysql, postgres)
2519

26-
protected[this] final def mysqlJdbcUrl = mysql.jdbcUrl
27-
protected[this] final def postgresJdbcUrl = postgres.jdbcUrl
20+
protected[this] final def mysqlJdbcUrl = mysql.getJdbcUrl
21+
protected[this] final def postgresJdbcUrl = postgres.getJdbcUrl
2822

2923
protected[this] final val asyncConnectionPoolSettings
3024
: AsyncConnectionPoolSettings = AsyncConnectionPoolSettings()
3125

32-
override def afterStart(): Unit = {
26+
override def beforeAll(): Unit = {
27+
super.beforeAll()
28+
mysql.start()
29+
postgres.start()
30+
3331
GlobalSettings.loggingSQLErrors = false
3432

3533
// default: PostgreSQL
3634
ConnectionPool.singleton(
3735
url = postgresJdbcUrl,
38-
user = postgres.username,
39-
password = postgres.password
36+
user = postgres.getUsername,
37+
password = postgres.getPassword
4038
)
4139
AsyncConnectionPool.singleton(
4240
url = postgresJdbcUrl,
43-
user = postgres.username,
44-
password = postgres.password,
41+
user = postgres.getUsername,
42+
password = postgres.getPassword,
4543
settings = asyncConnectionPoolSettings
4644
)
4745

@@ -52,14 +50,14 @@ trait DBSettings extends ForAllTestContainer { self: Suite =>
5250
ConnectionPool.add(
5351
"mysql",
5452
url = mysqlJdbcUrl,
55-
user = mysql.username,
56-
password = mysql.password
53+
user = mysql.getUsername,
54+
password = mysql.getPassword
5755
)
5856
AsyncConnectionPool.add(
5957
name = "mysql",
6058
url = mysqlJdbcUrl,
61-
user = mysql.username,
62-
password = mysql.password,
59+
user = mysql.getUsername,
60+
password = mysql.getPassword,
6361
settings = asyncConnectionPoolSettings
6462
)
6563

0 commit comments

Comments
 (0)