mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-10-27 00:26:15 +01:00
Update testcontainers
This commit is contained in:
@@ -62,9 +62,8 @@ libraryDependencies ++= Seq(
|
|||||||
"junit" % "junit" % "4.13.2" % "test",
|
"junit" % "junit" % "4.13.2" % "test",
|
||||||
"org.scalatra" %% "scalatra-scalatest-javax" % ScalatraVersion % "test",
|
"org.scalatra" %% "scalatra-scalatest-javax" % ScalatraVersion % "test",
|
||||||
"org.mockito" % "mockito-core" % "5.20.0" % "test",
|
"org.mockito" % "mockito-core" % "5.20.0" % "test",
|
||||||
"com.dimafeng" %% "testcontainers-scala" % "0.43.0" % "test",
|
"org.testcontainers" % "testcontainers-mysql" % "2.0.1" % "test",
|
||||||
"org.testcontainers" % "mysql" % "1.21.3" % "test",
|
"org.testcontainers" % "testcontainers-postgresql" % "2.0.1" % "test",
|
||||||
"org.testcontainers" % "postgresql" % "1.21.3" % "test",
|
|
||||||
"net.i2p.crypto" % "eddsa" % "0.3.0",
|
"net.i2p.crypto" % "eddsa" % "0.3.0",
|
||||||
"is.tagomor.woothee" % "woothee-java" % "1.11.0",
|
"is.tagomor.woothee" % "woothee-java" % "1.11.0",
|
||||||
"org.ec4j.core" % "ec4j-core" % "1.1.1",
|
"org.ec4j.core" % "ec4j-core" % "1.1.1",
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package gitbucket.core
|
package gitbucket.core
|
||||||
|
|
||||||
import java.sql.DriverManager
|
import java.sql.DriverManager
|
||||||
|
|
||||||
import com.dimafeng.testcontainers.{MySQLContainer, PostgreSQLContainer}
|
|
||||||
import io.github.gitbucket.solidbase.Solidbase
|
import io.github.gitbucket.solidbase.Solidbase
|
||||||
import io.github.gitbucket.solidbase.model.Module
|
import io.github.gitbucket.solidbase.model.Module
|
||||||
import liquibase.database.core.{H2Database, MySQLDatabase, PostgresDatabase}
|
import liquibase.database.core.{H2Database, MySQLDatabase, PostgresDatabase}
|
||||||
import org.junit.runner.Description
|
import org.junit.runner.Description
|
||||||
import org.scalatest.funsuite.AnyFunSuite
|
import org.scalatest.funsuite.AnyFunSuite
|
||||||
import org.scalatest.Tag
|
import org.scalatest.Tag
|
||||||
|
import org.testcontainers.postgresql.PostgreSQLContainer
|
||||||
|
import org.testcontainers.mysql.MySQLContainer
|
||||||
import org.testcontainers.utility.DockerImageName
|
import org.testcontainers.utility.DockerImageName
|
||||||
|
|
||||||
object ExternalDBTest extends Tag("ExternalDBTest")
|
object ExternalDBTest extends Tag("ExternalDBTest")
|
||||||
@@ -28,20 +28,17 @@ class GitBucketCoreModuleSpec extends AnyFunSuite {
|
|||||||
|
|
||||||
Seq("8.4", "5.7").foreach { tag =>
|
Seq("8.4", "5.7").foreach { tag =>
|
||||||
test(s"Migration MySQL $tag", ExternalDBTest) {
|
test(s"Migration MySQL $tag", ExternalDBTest) {
|
||||||
val container = new MySQLContainer() {
|
val container = new MySQLContainer(s"mysql:$tag") {
|
||||||
override val container: org.testcontainers.containers.MySQLContainer[?] =
|
|
||||||
new org.testcontainers.containers.MySQLContainer(s"mysql:$tag") {
|
|
||||||
override def getDriverClassName = "org.mariadb.jdbc.Driver"
|
override def getDriverClassName = "org.mariadb.jdbc.Driver"
|
||||||
override def getJdbcUrl: String = super.getJdbcUrl + "?permitMysqlScheme"
|
override def getJdbcUrl: String = super.getJdbcUrl + "?permitMysqlScheme"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
container.start()
|
container.start()
|
||||||
try {
|
try {
|
||||||
new Solidbase().migrate(
|
new Solidbase().migrate(
|
||||||
DriverManager.getConnection(
|
DriverManager.getConnection(
|
||||||
container.jdbcUrl,
|
container.getJdbcUrl,
|
||||||
container.username,
|
container.getUsername,
|
||||||
container.password
|
container.getPassword
|
||||||
),
|
),
|
||||||
Thread.currentThread().getContextClassLoader(),
|
Thread.currentThread().getContextClassLoader(),
|
||||||
new MySQLDatabase(),
|
new MySQLDatabase(),
|
||||||
@@ -55,12 +52,12 @@ class GitBucketCoreModuleSpec extends AnyFunSuite {
|
|||||||
|
|
||||||
Seq("11", "10").foreach { tag =>
|
Seq("11", "10").foreach { tag =>
|
||||||
test(s"Migration PostgreSQL $tag", ExternalDBTest) {
|
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()
|
container.start()
|
||||||
try {
|
try {
|
||||||
new Solidbase().migrate(
|
new Solidbase().migrate(
|
||||||
DriverManager.getConnection(container.jdbcUrl, container.username, container.password),
|
DriverManager.getConnection(container.getJdbcUrl, container.getUsername, container.getPassword),
|
||||||
Thread.currentThread().getContextClassLoader(),
|
Thread.currentThread().getContextClassLoader(),
|
||||||
new PostgresDatabase(),
|
new PostgresDatabase(),
|
||||||
new Module(GitBucketCoreModule.getModuleId, GitBucketCoreModule.getVersions)
|
new Module(GitBucketCoreModule.getModuleId, GitBucketCoreModule.getVersions)
|
||||||
|
|||||||
Reference in New Issue
Block a user