diff --git a/.travis.yml b/.travis.yml index eea05c1..bdf04e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: scala sudo: false script: - - sbt test + - sbt "test-only -- -l ExternalDBTest" jdk: - oraclejdk8 -before_script: - - psql -c "CREATE ROLE sa WITH SUPERUSER LOGIN PASSWORD 'sa';" -U postgres - - psql -c "CREATE DATABASE gitbucket;" -U postgres - - mysql -e 'GRANT ALL ON *.* TO sa@"localhost"IDENTIFIED BY "sa";FLUSH PRIVILEGES;' -uroot - - mysql -e "CREATE DATABASE gitbucket;" -usa -psa +#before_script: +# - psql -c "CREATE ROLE sa WITH SUPERUSER LOGIN PASSWORD 'sa';" -U postgres +# - psql -c "CREATE DATABASE gitbucket;" -U postgres +# - mysql -e 'GRANT ALL ON *.* TO sa@"localhost"IDENTIFIED BY "sa";FLUSH PRIVILEGES;' -uroot +# - mysql -e "CREATE DATABASE gitbucket;" -usa -psa diff --git a/build.sbt b/build.sbt index 088d2f3..88f5e53 100644 --- a/build.sbt +++ b/build.sbt @@ -62,10 +62,14 @@ scalacOptions := Seq("-deprecation", "-language:postfixOps", "-Ybackend:GenBCode", "-Ydelambdafy:method", "-target:jvm-1.8") javacOptions in compile ++= Seq("-target", "8", "-source", "8") javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml" -testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "junitxml", "console") + +// Test settings +//testOptions in Test += Tests.Argument("-l", "ExternalDBTest") javaOptions in Test += "-Dgitbucket.home=target/gitbucket_home_for_test" testOptions in Test += Tests.Setup( () => new java.io.File("target/gitbucket_home_for_test").mkdir() ) fork in Test := true + +// Packaging options packageOptions += Package.MainClass("JettyLauncher") // Assembly settings diff --git a/src/test/scala/gitbucket/core/GitBucketCoreModuleSpec.scala b/src/test/scala/gitbucket/core/GitBucketCoreModuleSpec.scala index b9f23e3..5967d42 100644 --- a/src/test/scala/gitbucket/core/GitBucketCoreModuleSpec.scala +++ b/src/test/scala/gitbucket/core/GitBucketCoreModuleSpec.scala @@ -5,7 +5,7 @@ import io.github.gitbucket.solidbase.Solidbase import io.github.gitbucket.solidbase.model.Module import liquibase.database.core.{H2Database, MySQLDatabase, PostgresDatabase} -import org.scalatest.FunSuite +import org.scalatest.{FunSuite, Tag} import com.wix.mysql.EmbeddedMysql._ import com.wix.mysql.config.Charset import com.wix.mysql.config.MysqldConfig._ @@ -15,6 +15,8 @@ import ru.yandex.qatools.embed.postgresql.config.PostgresConfig import ru.yandex.qatools.embed.postgresql.distribution.Version.Main.PRODUCTION +object ExternalDBTest extends Tag("ExternalDBTest") + class GitBucketCoreModuleSpec extends FunSuite { test("Migration H2"){ @@ -26,51 +28,51 @@ ) } - test("Migration MySQL"){ -// val config = aMysqldConfig(v5_7_10) -// .withPort(3306) -// .withUser("gitbucket", "gitbucket") -// .withCharset(Charset.UTF8) -// .build() -// -// val mysqld = anEmbeddedMysql(config) -// .addSchema("gitbucket") -// .start() -// -// try { + test("Migration MySQL", ExternalDBTest){ + val config = aMysqldConfig(v5_7_10) + .withPort(3306) + .withUser("sa", "sa") + .withCharset(Charset.UTF8) + .build() + + val mysqld = anEmbeddedMysql(config) + .addSchema("gitbucket") + .start() + + try { new Solidbase().migrate( DriverManager.getConnection("jdbc:mysql://localhost:3306/gitbucket", "sa", "sa"), Thread.currentThread().getContextClassLoader(), new MySQLDatabase(), new Module(GitBucketCoreModule.getModuleId, GitBucketCoreModule.getVersions) ) -// } finally { -// mysqld.stop() -// } + } finally { + mysqld.stop() + } } - test("Migration PostgreSQL"){ -// val runtime = PostgresStarter.getDefaultInstance() -// val config = new PostgresConfig( -// PRODUCTION, -// new Net("localhost", 5432), -// new Storage("gitbucket"), -// new Timeout(), -// new Credentials("root", "root")) -// -// val exec = runtime.prepare(config) -// val process = exec.start() -// -// try { + test("Migration PostgreSQL", ExternalDBTest){ + val runtime = PostgresStarter.getDefaultInstance() + val config = new PostgresConfig( + PRODUCTION, + new Net("localhost", 5432), + new Storage("gitbucket"), + new Timeout(), + new Credentials("sa", "sa")) + + val exec = runtime.prepare(config) + val process = exec.start() + + try { new Solidbase().migrate( DriverManager.getConnection("jdbc:postgresql://localhost:5432/gitbucket", "sa", "sa"), Thread.currentThread().getContextClassLoader(), new PostgresDatabase(), new Module(GitBucketCoreModule.getModuleId, GitBucketCoreModule.getVersions) ) -// } finally { -// process.stop() -// } + } finally { + process.stop() + } } }