From 6bc19a03aa101e999f7a9929d2252032dd56ec46 Mon Sep 17 00:00:00 2001 From: Adrien Piquerez Date: Mon, 28 Nov 2022 10:34:37 +0100 Subject: [PATCH] Update Flyway and Elastic4s --- build.sbt | 4 +- .../scala/scaladex/infra/SqlDatabase.scala | 6 +- .../infra/migrations/FlywayMigration.scala | 29 ++++++++++ .../migrations/ScaladexBaseMigration.scala | 27 --------- .../V11_2__add_data_to_the_new_tables.scala | 25 +++----- ...13_2__update_new_fields_in_artifacts.scala | 34 ++++------- .../migrations/V17__add_mill_platform.scala | 18 +++--- .../V7_2__edit_platform_and_language.scala | 32 ++++------- .../V9__fix_platform_and_language.scala | 34 ++++------- .../scaladex/infra/sql/DoobieUtils.scala | 7 +-- .../scaladex/infra/BaseDatabaseSuite.scala | 57 ------------------- .../scala/scaladex/infra/DatabaseSuite.scala | 44 ++++++++++++++ .../scaladex/infra/SqlDatabaseTests.scala | 2 +- .../sql/ArtifactDependencyTableTests.scala | 4 +- .../infra/sql/ArtifactTableTests.scala | 4 +- .../infra/sql/GithubInfoTableTests.scala | 4 +- .../sql/ProjectDependenciesTableTests.scala | 4 +- .../infra/sql/ProjectSettingsTableTests.scala | 4 +- .../infra/sql/ProjectTableTests.scala | 4 +- .../sql/ReleaseDependenciesTableTests.scala | 4 +- .../infra/sql/ReleaseTableTests.scala | 4 +- .../infra/sql/UserSessionsTableTests.scala | 4 +- .../src/it/scala/scaladex/RelevanceTest.scala | 2 +- 23 files changed, 150 insertions(+), 207 deletions(-) create mode 100644 modules/infra/src/main/scala/scaladex/infra/migrations/FlywayMigration.scala delete mode 100644 modules/infra/src/main/scala/scaladex/infra/migrations/ScaladexBaseMigration.scala delete mode 100644 modules/infra/src/test/scala/scaladex/infra/BaseDatabaseSuite.scala create mode 100644 modules/infra/src/test/scala/scaladex/infra/DatabaseSuite.scala diff --git a/build.sbt b/build.sbt index 598da260c..3eb0a324c 100644 --- a/build.sbt +++ b/build.sbt @@ -67,7 +67,7 @@ lazy val infra = project libraryDependencies ++= Seq( "com.sksamuel.elastic4s" %% "elastic4s-client-esjava" % V.elastic4sVersion, "org.json4s" %% "json4s-native" % V.json4s, - "org.flywaydb" % "flyway-core" % "8.5.13", // for database migration + "org.flywaydb" % "flyway-core" % "9.8.3", // for database migration "com.typesafe.akka" %% "akka-stream" % V.akkaVersion, "com.typesafe.akka" %% "akka-http" % V.akkaHttpVersion, "de.heikoseeberger" %% "akka-http-circe" % "1.39.2", @@ -244,7 +244,7 @@ lazy val V = new { val playJsonVersion = "2.9.3" val akkaVersion = "2.6.18" val akkaHttpVersion = "10.2.10" - val elastic4sVersion = "8.4.4" + val elastic4sVersion = "8.5.0" val nscalaTimeVersion = "2.32.0" val scalatest = "3.2.14" val circeVersion = "0.14.3" diff --git a/modules/infra/src/main/scala/scaladex/infra/SqlDatabase.scala b/modules/infra/src/main/scala/scaladex/infra/SqlDatabase.scala index 9301a5c37..77eec5af8 100644 --- a/modules/infra/src/main/scala/scaladex/infra/SqlDatabase.scala +++ b/modules/infra/src/main/scala/scaladex/infra/SqlDatabase.scala @@ -34,8 +34,10 @@ import scaladex.infra.sql.ReleaseDependenciesTable import scaladex.infra.sql.ReleaseTable import scaladex.infra.sql.UserSessionsTable -class SqlDatabase(datasource: HikariDataSource, xa: doobie.Transactor[IO]) extends SchedulerDatabase with LazyLogging { - private val flyway = DoobieUtils.flyway(datasource) +class SqlDatabase(datasource: HikariDataSource, xa: doobie.Transactor[IO], testMode: Boolean = false) + extends SchedulerDatabase + with LazyLogging { + private val flyway = DoobieUtils.flyway(datasource, testMode) def migrate: IO[Unit] = IO(flyway.migrate()) def dropTables: IO[Unit] = IO(flyway.clean()) diff --git a/modules/infra/src/main/scala/scaladex/infra/migrations/FlywayMigration.scala b/modules/infra/src/main/scala/scaladex/infra/migrations/FlywayMigration.scala new file mode 100644 index 000000000..31397d71a --- /dev/null +++ b/modules/infra/src/main/scala/scaladex/infra/migrations/FlywayMigration.scala @@ -0,0 +1,29 @@ +package scaladex.infra.migrations + +import scala.concurrent.ExecutionContext + +import cats.effect.ContextShift +import cats.effect.IO +import com.typesafe.scalalogging.LazyLogging +import doobie.implicits._ +import doobie.util.transactor.Transactor +import org.flywaydb.core.api.migration.BaseJavaMigration +import org.flywaydb.core.api.migration.Context +import scaladex.infra.config.PostgreSQLConfig + +abstract class FlywayMigration extends BaseJavaMigration with LazyLogging { + def migrationIO: IO[Unit] + + def run[A](v: doobie.ConnectionIO[A]): IO[A] = + v.transact(FlywayMigration.transactor) + + override def migrate(context: Context): Unit = + migrationIO.unsafeRunSync() +} + +object FlywayMigration { + private implicit val cs: ContextShift[IO] = IO.contextShift(ExecutionContext.global) + private val config = PostgreSQLConfig.load().get + private val transactor: Transactor.Aux[IO, Unit] = + Transactor.fromDriverManager[IO](config.driver, config.url, config.user, config.pass.decode) +} diff --git a/modules/infra/src/main/scala/scaladex/infra/migrations/ScaladexBaseMigration.scala b/modules/infra/src/main/scala/scaladex/infra/migrations/ScaladexBaseMigration.scala deleted file mode 100644 index 9935eba35..000000000 --- a/modules/infra/src/main/scala/scaladex/infra/migrations/ScaladexBaseMigration.scala +++ /dev/null @@ -1,27 +0,0 @@ -package scaladex.infra.migrations - -import scala.concurrent.ExecutionContext - -import cats.effect.ContextShift -import cats.effect.IO -import doobie.implicits._ -import doobie.util.transactor.Transactor -import scaladex.infra.config.PostgreSQLConfig - -trait ScaladexBaseMigration { - private implicit val cs: ContextShift[IO] = - IO.contextShift(ExecutionContext.global) - - private val config = PostgreSQLConfig.load().get - val xa: Transactor.Aux[IO, Unit] = - Transactor - .fromDriverManager[IO]( - config.driver, - config.url, - config.user, - config.pass.decode - ) - - def run[A](xa: doobie.Transactor[IO])(v: doobie.ConnectionIO[A]): IO[A] = - v.transact(xa) -} diff --git a/modules/infra/src/main/scala/scaladex/infra/migrations/V11_2__add_data_to_the_new_tables.scala b/modules/infra/src/main/scala/scaladex/infra/migrations/V11_2__add_data_to_the_new_tables.scala index a69c246cd..352a3ef38 100644 --- a/modules/infra/src/main/scala/scaladex/infra/migrations/V11_2__add_data_to_the_new_tables.scala +++ b/modules/infra/src/main/scala/scaladex/infra/migrations/V11_2__add_data_to_the_new_tables.scala @@ -1,24 +1,13 @@ package scaladex.infra.migrations -import com.typesafe.scalalogging.LazyLogging -import org.flywaydb.core.api.migration.BaseJavaMigration -import org.flywaydb.core.api.migration.Context +import cats.effect.IO import scaladex.infra.sql.ArtifactTable import scaladex.infra.sql.ReleaseTable -class V11_2__add_data_to_the_new_tables extends BaseJavaMigration with ScaladexBaseMigration with LazyLogging { - override def migrate(context: Context): Unit = - try { - (for { - releases <- run(xa)(ArtifactTable.getReleasesFromArtifacts.to[Seq]) - _ <- run(xa)(ReleaseTable.insertIfNotExists.updateMany(releases)) - } yield ()) - .unsafeRunSync() - - } catch { - case e: Throwable => - logger.info("failed to migrate the database") - throw new Exception(s"failed to migrate the database because of ${e.getMessage}") - } - +class V11_2__add_data_to_the_new_tables extends FlywayMigration { + override def migrationIO: IO[Unit] = + for { + releases <- run(ArtifactTable.getReleasesFromArtifacts.to[Seq]) + _ <- run(ReleaseTable.insertIfNotExists.updateMany(releases)) + } yield () } diff --git a/modules/infra/src/main/scala/scaladex/infra/migrations/V13_2__update_new_fields_in_artifacts.scala b/modules/infra/src/main/scala/scaladex/infra/migrations/V13_2__update_new_fields_in_artifacts.scala index e83f767de..6529693b3 100644 --- a/modules/infra/src/main/scala/scaladex/infra/migrations/V13_2__update_new_fields_in_artifacts.scala +++ b/modules/infra/src/main/scala/scaladex/infra/migrations/V13_2__update_new_fields_in_artifacts.scala @@ -1,36 +1,26 @@ package scaladex.infra.migrations +import cats.effect.IO import cats.implicits._ -import com.typesafe.scalalogging.LazyLogging import doobie.Query0 import doobie.util.update.Update -import org.flywaydb.core.api.migration.BaseJavaMigration -import org.flywaydb.core.api.migration.Context import scaladex.core.model.Artifact import scaladex.core.model.Artifact.MavenReference import scaladex.infra.sql.DoobieUtils.Mappings._ import scaladex.infra.sql.DoobieUtils.selectRequest import scaladex.infra.sql.DoobieUtils.updateRequest -class V13_2__update_new_fields_in_artifacts extends BaseJavaMigration with ScaladexBaseMigration with LazyLogging { - override def migrate(context: Context): Unit = - try { - (for { - oldArtifacts <- run(xa)(selectArtifact.to[Seq]) - groupedArtifacts = oldArtifacts.grouped(10000).toSeq - _ <- groupedArtifacts - .map(artifacts => run(xa)(updateNewFields.updateMany(artifacts.map(update)))) - .sequence - } yield ()) - .unsafeRunSync() +class V13_2__update_new_fields_in_artifacts extends FlywayMigration { + override def migrationIO: IO[Unit] = + for { + oldArtifacts <- run(selectArtifact.to[Seq]) + groupedArtifacts = oldArtifacts.grouped(10000).toSeq + _ <- groupedArtifacts + .map(artifacts => run(updateNewFields.updateMany(artifacts.map(update)))) + .sequence + } yield () - } catch { - case e: Throwable => - logger.info("failed to migrate the database") - throw new Exception(s"failed to migrate the database because of ${e.getMessage}") - } - - val selectArtifact: Query0[Artifact] = selectRequest("artifacts", Seq("*")) - val updateNewFields: Update[(Boolean, Boolean, MavenReference)] = + private val selectArtifact: Query0[Artifact] = selectRequest("artifacts", Seq("*")) + private val updateNewFields: Update[(Boolean, Boolean, MavenReference)] = updateRequest("artifacts", Seq("is_semantic", "is_prerelease"), Seq("group_id", "artifact_id", "version")) private def update(artifact: Artifact): (Boolean, Boolean, MavenReference) = diff --git a/modules/infra/src/main/scala/scaladex/infra/migrations/V17__add_mill_platform.scala b/modules/infra/src/main/scala/scaladex/infra/migrations/V17__add_mill_platform.scala index 23fa4fd89..bb66ba420 100644 --- a/modules/infra/src/main/scala/scaladex/infra/migrations/V17__add_mill_platform.scala +++ b/modules/infra/src/main/scala/scaladex/infra/migrations/V17__add_mill_platform.scala @@ -1,27 +1,23 @@ package scaladex.infra.migrations -import com.typesafe.scalalogging.LazyLogging +import cats.effect.IO import doobie._ -import org.flywaydb.core.api.migration.BaseJavaMigration -import org.flywaydb.core.api.migration.Context import scaladex.core.model._ import scaladex.infra.sql.DoobieUtils.Mappings._ import scaladex.infra.sql.DoobieUtils._ -class V17__add_mill_platform extends BaseJavaMigration with ScaladexBaseMigration with LazyLogging { - override def migrate(context: Context): Unit = { - val migrateIO = for { - oldArtifacts <- run(xa)(selectArtifact.to[Seq]) +class V17__add_mill_platform extends FlywayMigration { + override def migrationIO: IO[Unit] = + for { + oldArtifacts <- run(selectArtifact.to[Seq]) newArtifacts = oldArtifacts.map { a => val newId = Artifact.ArtifactId.parse(a.artifactId).get a.copy(artifactName = newId.name, platform = newId.binaryVersion.platform) } (toUpdate, toDelete) = newArtifacts.partition(a => isValidMillPlugin(a)) - _ <- run(xa)(updateNewFields.updateMany(toUpdate.map(update))) - _ <- run(xa)(delete.updateMany(toDelete.map(_.mavenReference))) + _ <- run(updateNewFields.updateMany(toUpdate.map(update))) + _ <- run(delete.updateMany(toDelete.map(_.mavenReference))) } yield () - migrateIO.unsafeRunSync() - } val selectArtifact: Query0[Artifact] = selectRequest("artifacts", Seq("*"), where = Seq("artifact_name LIKE '%_mill0_%'")) diff --git a/modules/infra/src/main/scala/scaladex/infra/migrations/V7_2__edit_platform_and_language.scala b/modules/infra/src/main/scala/scaladex/infra/migrations/V7_2__edit_platform_and_language.scala index 1e583427b..d34c03f16 100644 --- a/modules/infra/src/main/scala/scaladex/infra/migrations/V7_2__edit_platform_and_language.scala +++ b/modules/infra/src/main/scala/scaladex/infra/migrations/V7_2__edit_platform_and_language.scala @@ -2,40 +2,30 @@ package scaladex.infra.migrations import java.time.Instant +import cats.effect.IO import cats.implicits._ -import com.typesafe.scalalogging.LazyLogging import doobie.Query0 import doobie.implicits._ import doobie.util.update.Update -import org.flywaydb.core.api.migration.BaseJavaMigration -import org.flywaydb.core.api.migration.Context import scaladex.core.model.Artifact.MavenReference import scaladex.core.model._ import scaladex.infra.sql.DoobieUtils.Mappings._ import scaladex.infra.sql.DoobieUtils.selectRequest import scaladex.infra.sql.DoobieUtils.updateRequest -class V7_2__edit_platform_and_language extends BaseJavaMigration with ScaladexBaseMigration with LazyLogging { +class V7_2__edit_platform_and_language extends FlywayMigration { import V7_2__edit_platform_and_language._ - override def migrate(context: Context): Unit = - try { - (for { - oldArtifacts <- run(xa)(selectArtifact.to[Seq]) - groupedArtifacts = oldArtifacts.grouped(10000).toSeq - _ <- groupedArtifacts - .map(artifacts => run(xa)(updatePlatformAndLanguage.updateMany(artifacts.map(_.update)))) - .sequence - _ <- run(xa)(sql"ALTER TABLE artifacts DROP COLUMN binary_version".update.run) - } yield ()) - .unsafeRunSync() - - } catch { - case e: Throwable => - logger.info("failed to migrate the database") - throw new Exception(s"failed to migrate the database because of ${e.getMessage}") - } + override def migrationIO: IO[Unit] = + for { + oldArtifacts <- run(selectArtifact.to[Seq]) + groupedArtifacts = oldArtifacts.grouped(10000).toSeq + _ <- groupedArtifacts + .map(artifacts => run(updatePlatformAndLanguage.updateMany(artifacts.map(_.update)))) + .sequence + _ <- run(sql"ALTER TABLE artifacts DROP COLUMN binary_version".update.run) + } yield () val selectArtifact: Query0[OldArtifact] = selectRequest("artifacts", Seq("*")) diff --git a/modules/infra/src/main/scala/scaladex/infra/migrations/V9__fix_platform_and_language.scala b/modules/infra/src/main/scala/scaladex/infra/migrations/V9__fix_platform_and_language.scala index 5540ca911..136e1cb5e 100644 --- a/modules/infra/src/main/scala/scaladex/infra/migrations/V9__fix_platform_and_language.scala +++ b/modules/infra/src/main/scala/scaladex/infra/migrations/V9__fix_platform_and_language.scala @@ -1,34 +1,24 @@ package scaladex.infra.migrations -import com.typesafe.scalalogging.LazyLogging +import cats.effect.IO import doobie.Query0 import doobie.util.update.Update -import org.flywaydb.core.api.migration.BaseJavaMigration -import org.flywaydb.core.api.migration.Context import scaladex.core.model.Artifact.MavenReference import scaladex.core.model._ import scaladex.infra.sql.DoobieUtils.Mappings._ import scaladex.infra.sql.DoobieUtils.selectRequest import scaladex.infra.sql.DoobieUtils.updateRequest -class V9__fix_platform_and_language extends BaseJavaMigration with ScaladexBaseMigration with LazyLogging { - override def migrate(context: Context): Unit = - try { - (for { - artifactToFix <- run(xa)(selectArtifact.to[Seq]) - artifactToFixWithIds = artifactToFix.flatMap(a => Artifact.ArtifactId.parse(a.artifactId).map(a -> _)) - _ <- run(xa) { - updatePlatformAndLanguage.updateMany(artifactToFixWithIds.map { - case (artifact, id) => (id.binaryVersion.platform, id.binaryVersion.language, artifact.mavenReference) - }) - } - } yield ()) - .unsafeRunSync() - - } catch { - case e: Throwable => - logger.info("failed to migrate the database") - throw new Exception(s"failed to migrate the database because of ${e.getMessage}") - } +class V9__fix_platform_and_language extends FlywayMigration { + override def migrationIO: IO[Unit] = + for { + artifactToFix <- run(selectArtifact.to[Seq]) + artifactToFixWithIds = artifactToFix.flatMap(a => Artifact.ArtifactId.parse(a.artifactId).map(a -> _)) + _ <- run { + updatePlatformAndLanguage.updateMany(artifactToFixWithIds.map { + case (artifact, id) => (id.binaryVersion.platform, id.binaryVersion.language, artifact.mavenReference) + }) + } + } yield () val selectArtifact: Query0[Artifact] = selectRequest("artifacts", Seq("*"), where = Seq("language_version = 'Java'", "version ~ '^[^.]*$'")) diff --git a/modules/infra/src/main/scala/scaladex/infra/sql/DoobieUtils.scala b/modules/infra/src/main/scala/scaladex/infra/sql/DoobieUtils.scala index d2455ee2b..20bc49a71 100644 --- a/modules/infra/src/main/scala/scaladex/infra/sql/DoobieUtils.scala +++ b/modules/infra/src/main/scala/scaladex/infra/sql/DoobieUtils.scala @@ -43,14 +43,11 @@ object DoobieUtils { private implicit val cs: ContextShift[IO] = IO.contextShift(ExecutionContext.global) - def flyway(conf: PostgreSQLConfig): Flyway = { - val datasource = getHikariDataSource(conf) - flyway(datasource) - } - def flyway(datasource: HikariDataSource): Flyway = + def flyway(datasource: HikariDataSource, testMode: Boolean): Flyway = Flyway .configure() .dataSource(datasource) + .cleanDisabled(!testMode) .locations("migrations", "scaladex/infra/migrations") .load() diff --git a/modules/infra/src/test/scala/scaladex/infra/BaseDatabaseSuite.scala b/modules/infra/src/test/scala/scaladex/infra/BaseDatabaseSuite.scala deleted file mode 100644 index cb9e73c83..000000000 --- a/modules/infra/src/test/scala/scaladex/infra/BaseDatabaseSuite.scala +++ /dev/null @@ -1,57 +0,0 @@ -package scaladex.infra - -import scala.concurrent.Await -import scala.concurrent.ExecutionContext -import scala.concurrent.Future -import scala.concurrent.duration.Duration - -import cats.effect.ContextShift -import cats.effect.IO -import com.zaxxer.hikari.HikariDataSource -import doobie.scalatest.IOChecker -import doobie.util.transactor.Transactor -import org.scalatest.Assertions -import org.scalatest.BeforeAndAfterEach -import org.scalatest.Suite -import scaladex.infra.config.PostgreSQLConfig -import scaladex.infra.sql.DoobieUtils - -trait BaseDatabaseSuite extends IOChecker with BeforeAndAfterEach { - self: Assertions with Suite => - - private implicit val cs: ContextShift[IO] = - IO.contextShift(ExecutionContext.global) - - private val config: PostgreSQLConfig = PostgreSQLConfig - .load() - .get - - override val transactor: Transactor.Aux[IO, Unit] = - Transactor - .fromDriverManager[IO]( - config.driver, - config.url, - config.user, - config.pass.decode - ) - - lazy val database = new SqlDatabase(BaseDatabaseSuite.datasource, transactor) - - override def beforeEach(): Unit = - Await.result(cleanTables(), Duration.Inf) - - private def cleanTables(): Future[Unit] = { - val reset = for { - _ <- database.dropTables - _ <- database.migrate - } yield () - reset.unsafeToFuture() - } -} -object BaseDatabaseSuite { - private val config: PostgreSQLConfig = PostgreSQLConfig - .load() - .get - - val datasource: HikariDataSource = DoobieUtils.getHikariDataSource(config) -} diff --git a/modules/infra/src/test/scala/scaladex/infra/DatabaseSuite.scala b/modules/infra/src/test/scala/scaladex/infra/DatabaseSuite.scala new file mode 100644 index 000000000..2e1707232 --- /dev/null +++ b/modules/infra/src/test/scala/scaladex/infra/DatabaseSuite.scala @@ -0,0 +1,44 @@ +package scaladex.infra + +import scala.concurrent.Await +import scala.concurrent.Future +import scala.concurrent.duration.Duration + +import cats.effect.IO +import com.zaxxer.hikari.HikariDataSource +import doobie.scalatest.IOChecker +import doobie.util.transactor.Transactor +import org.scalatest.BeforeAndAfterEach +import org.scalatest.Suite +import scaladex.infra.config.PostgreSQLConfig +import scaladex.infra.sql.DoobieUtils + +trait DatabaseSuite extends IOChecker with BeforeAndAfterEach { + self: Suite => + + override val transactor: Transactor[IO] = DatabaseSuite.transactor + + lazy val database = new SqlDatabase(DatabaseSuite.dataSource, transactor, testMode = true) + + override def beforeEach(): Unit = + Await.result(cleanTables(), Duration.Inf) + + private def cleanTables(): Future[Unit] = { + val reset = for { + _ <- database.dropTables + _ <- database.migrate + } yield () + reset.unsafeToFuture() + } +} + +object DatabaseSuite { + private val config: PostgreSQLConfig = PostgreSQLConfig.load().get + + // The datasource for the tests is global + // Otherwise we need to close it after running a test suite + private val dataSource: HikariDataSource = DoobieUtils.getHikariDataSource(config) + + private val transactor = + DoobieUtils.transactor(dataSource).use(IO.pure).unsafeRunSync() +} diff --git a/modules/infra/src/test/scala/scaladex/infra/SqlDatabaseTests.scala b/modules/infra/src/test/scala/scaladex/infra/SqlDatabaseTests.scala index 4444cfd44..dbcc55db9 100644 --- a/modules/infra/src/test/scala/scaladex/infra/SqlDatabaseTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/SqlDatabaseTests.scala @@ -24,7 +24,7 @@ import scaladex.core.model.UserState import scaladex.core.util.ScalaExtensions._ import scaladex.core.util.Secret -class SqlDatabaseTests extends AsyncFunSpec with BaseDatabaseSuite with Matchers { +class SqlDatabaseTests extends AsyncFunSpec with DatabaseSuite with Matchers { val executorService: ExecutorService = Executors.newFixedThreadPool(1) override implicit val executionContext: ExecutionContext = diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactDependencyTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactDependencyTableTests.scala index 051596714..90c17baab 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactDependencyTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactDependencyTableTests.scala @@ -2,10 +2,10 @@ package scaladex.infra.sql import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers -import scaladex.infra.BaseDatabaseSuite +import scaladex.infra.DatabaseSuite import scaladex.infra.sql.ArtifactDependencyTable -class ArtifactDependencyTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { +class ArtifactDependencyTableTests extends AnyFunSpec with DatabaseSuite with Matchers { it("check insertIfNotExist")(check(ArtifactDependencyTable.insertIfNotExist)) it("check select")(check(ArtifactDependencyTable.select)) it("check selectDirectDependency")(check(ArtifactDependencyTable.selectDirectDependency)) diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactTableTests.scala index 5af529486..bfd973c6f 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactTableTests.scala @@ -6,9 +6,9 @@ import scaladex.core.model.Jvm import scaladex.core.model.Scala import scaladex.core.model.ScalaJs import scaladex.core.test.Values._ -import scaladex.infra.BaseDatabaseSuite +import scaladex.infra.DatabaseSuite -class ArtifactTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { +class ArtifactTableTests extends AnyFunSpec with DatabaseSuite with Matchers { import ArtifactTable._ it("check insertIfNotExist")(check(insertIfNotExist)) it("check selectAllArtifacts") { diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/GithubInfoTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/GithubInfoTableTests.scala index 4498de0a1..4bcfc7a4f 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/GithubInfoTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/GithubInfoTableTests.scala @@ -2,10 +2,10 @@ package scaladex.infra.sql import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers -import scaladex.infra.BaseDatabaseSuite +import scaladex.infra.DatabaseSuite import scaladex.infra.sql.GithubInfoTable -class GithubInfoTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { +class GithubInfoTableTests extends AnyFunSpec with DatabaseSuite with Matchers { it("check insert")(check(GithubInfoTable.insert)) it("check insertOrUpdate")(check(GithubInfoTable.insertOrUpdate)) } diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ProjectDependenciesTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ProjectDependenciesTableTests.scala index add217c6b..dd0372e47 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ProjectDependenciesTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/ProjectDependenciesTableTests.scala @@ -2,10 +2,10 @@ package scaladex.infra.sql import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers -import scaladex.infra.BaseDatabaseSuite +import scaladex.infra.DatabaseSuite import scaladex.infra.sql.ProjectDependenciesTable -class ProjectDependenciesTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { +class ProjectDependenciesTableTests extends AnyFunSpec with DatabaseSuite with Matchers { it("check insertOrUpdate")(check(ProjectDependenciesTable.insertOrUpdate)) it("check deleteBySource")(check(ProjectDependenciesTable.deleteBySource)) it("check getDependencies")(check(ProjectDependenciesTable.getDependencies)) diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ProjectSettingsTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ProjectSettingsTableTests.scala index 25c272b2d..27d3b891f 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ProjectSettingsTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/ProjectSettingsTableTests.scala @@ -2,9 +2,9 @@ package scaladex.infra.sql import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers -import scaladex.infra.BaseDatabaseSuite +import scaladex.infra.DatabaseSuite -class ProjectSettingsTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { +class ProjectSettingsTableTests extends AnyFunSpec with DatabaseSuite with Matchers { describe("should generate query for") { it("check insertOrUpdate")(check(ProjectSettingsTable.insertOrUpdate)) } diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ProjectTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ProjectTableTests.scala index 8ca5a02b6..30501a634 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ProjectTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/ProjectTableTests.scala @@ -2,10 +2,10 @@ package scaladex.infra.sql import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers -import scaladex.infra.BaseDatabaseSuite +import scaladex.infra.DatabaseSuite import scaladex.infra.sql.ProjectTable -class ProjectTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { +class ProjectTableTests extends AnyFunSpec with DatabaseSuite with Matchers { it("check insertIfNotExists")(check(ProjectTable.insertIfNotExists)) it("check updateCreationDate")(check(ProjectTable.updateCreationDate)) it("check updateGithubStatus")(check(ProjectTable.updateGithubStatus)) diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseDependenciesTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseDependenciesTableTests.scala index a57beb4b7..03edcbca1 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseDependenciesTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseDependenciesTableTests.scala @@ -2,8 +2,8 @@ package scaladex.infra.sql import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers -import scaladex.infra.BaseDatabaseSuite +import scaladex.infra.DatabaseSuite -class ReleaseDependenciesTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { +class ReleaseDependenciesTableTests extends AnyFunSpec with DatabaseSuite with Matchers { it("check insertIfNotExists")(check(ReleaseDependenciesTable.insertIfNotExists)) } diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseTableTests.scala index 3ef958076..4a4af80f3 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseTableTests.scala @@ -2,8 +2,8 @@ package scaladex.infra.sql import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers -import scaladex.infra.BaseDatabaseSuite +import scaladex.infra.DatabaseSuite -class ReleaseTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { +class ReleaseTableTests extends AnyFunSpec with DatabaseSuite with Matchers { it("check insertIfNotExists")(check(ReleaseTable.insertIfNotExists)) } diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/UserSessionsTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/UserSessionsTableTests.scala index 5846c63e7..9e073164c 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/UserSessionsTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/UserSessionsTableTests.scala @@ -2,9 +2,9 @@ package scaladex.infra.sql import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers -import scaladex.infra.BaseDatabaseSuite +import scaladex.infra.DatabaseSuite -class UserSessionsTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { +class UserSessionsTableTests extends AnyFunSpec with DatabaseSuite with Matchers { it("check insertOrUpdate")(check(UserSessionsTable.insertOrUpdate)) it("check selectUserSessionById")(check(UserSessionsTable.selectUserSessionById)) it("check selectAllUserSessions")(check(UserSessionsTable.selectAllUserSessions)) diff --git a/modules/server/src/it/scala/scaladex/RelevanceTest.scala b/modules/server/src/it/scala/scaladex/RelevanceTest.scala index 63f5131ce..1556469b6 100644 --- a/modules/server/src/it/scala/scaladex/RelevanceTest.scala +++ b/modules/server/src/it/scala/scaladex/RelevanceTest.scala @@ -33,7 +33,7 @@ class RelevanceTest extends TestKit(ActorSystem("SbtActorTest")) with AsyncFunSu val transactor = DoobieUtils.transactor(datasource) transactor .use { xa => - val database = new SqlDatabase(datasource, xa) + val database = new SqlDatabase(datasource, xa, testMode = true) val filesystem = FilesystemStorage(config.filesystem) val searchSync = new SearchSynchronizer(database, searchEngine)