Update testcontainers

This commit is contained in:
xuwei-k
2025-10-20 07:50:49 +09:00
committed by kenji yoshida
parent 72a354931e
commit 2fbdead64b
2 changed files with 36 additions and 40 deletions

View File

@@ -62,9 +62,8 @@ libraryDependencies ++= Seq(
"junit" % "junit" % "4.13.2" % "test",
"org.scalatra" %% "scalatra-scalatest-javax" % ScalatraVersion % "test",
"org.mockito" % "mockito-core" % "5.20.0" % "test",
"com.dimafeng" %% "testcontainers-scala" % "0.43.0" % "test",
"org.testcontainers" % "mysql" % "1.21.3" % "test",
"org.testcontainers" % "postgresql" % "1.21.3" % "test",
"org.testcontainers" % "testcontainers-mysql" % "2.0.1" % "test",
"org.testcontainers" % "testcontainers-postgresql" % "2.0.1" % "test",
"net.i2p.crypto" % "eddsa" % "0.3.0",
"is.tagomor.woothee" % "woothee-java" % "1.11.0",
"org.ec4j.core" % "ec4j-core" % "1.1.1",

View File

@@ -1,14 +1,14 @@
package gitbucket.core
import java.sql.DriverManager
import com.dimafeng.testcontainers.{MySQLContainer, PostgreSQLContainer}
import io.github.gitbucket.solidbase.Solidbase
import io.github.gitbucket.solidbase.model.Module
import liquibase.database.core.{H2Database, MySQLDatabase, PostgresDatabase}
import org.junit.runner.Description
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.Tag
import org.testcontainers.postgresql.PostgreSQLContainer
import org.testcontainers.mysql.MySQLContainer
import org.testcontainers.utility.DockerImageName
object ExternalDBTest extends Tag("ExternalDBTest")
@@ -28,20 +28,17 @@ class GitBucketCoreModuleSpec extends AnyFunSuite {
Seq("8.4", "5.7").foreach { tag =>
test(s"Migration MySQL $tag", ExternalDBTest) {
val container = new MySQLContainer() {
override val container: org.testcontainers.containers.MySQLContainer[?] =
new org.testcontainers.containers.MySQLContainer(s"mysql:$tag") {
val container = new MySQLContainer(s"mysql:$tag") {
override def getDriverClassName = "org.mariadb.jdbc.Driver"
override def getJdbcUrl: String = super.getJdbcUrl + "?permitMysqlScheme"
}
}
container.start()
try {
new Solidbase().migrate(
DriverManager.getConnection(
container.jdbcUrl,
container.username,
container.password
container.getJdbcUrl,
container.getUsername,
container.getPassword
),
Thread.currentThread().getContextClassLoader(),
new MySQLDatabase(),
@@ -55,12 +52,12 @@ class GitBucketCoreModuleSpec extends AnyFunSuite {
Seq("11", "10").foreach { tag =>
test(s"Migration PostgreSQL $tag", ExternalDBTest) {
val container = PostgreSQLContainer(DockerImageName.parse(s"postgres:$tag"))
val container = new PostgreSQLContainer(DockerImageName.parse(s"postgres:$tag"))
container.start()
try {
new Solidbase().migrate(
DriverManager.getConnection(container.jdbcUrl, container.username, container.password),
DriverManager.getConnection(container.getJdbcUrl, container.getUsername, container.getPassword),
Thread.currentThread().getContextClassLoader(),
new PostgresDatabase(),
new Module(GitBucketCoreModule.getModuleId, GitBucketCoreModule.getVersions)