mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 02:48:26 +00:00
@ -22,13 +22,15 @@ import org.mariadb.jdbc.MariaDbDataSource
|
||||
import org.postgresql.ds.PGConnectionPoolDataSource
|
||||
|
||||
trait StoreFixture extends CatsEffectFunFixtures { self: CatsEffectSuite =>
|
||||
def schemaMigrateConfig =
|
||||
StoreFixture.schemaMigrateConfig
|
||||
|
||||
val xa = ResourceFixture {
|
||||
val cfg = StoreFixture.memoryDB("test")
|
||||
for {
|
||||
ds <- StoreFixture.dataSource(cfg)
|
||||
xa <- StoreFixture.makeXA(ds)
|
||||
_ <- Resource.eval(FlywayMigrate[IO](cfg, xa).run)
|
||||
_ <- Resource.eval(FlywayMigrate[IO](cfg, schemaMigrateConfig, xa).run)
|
||||
} yield xa
|
||||
}
|
||||
|
||||
@ -42,6 +44,7 @@ trait StoreFixture extends CatsEffectFunFixtures { self: CatsEffectSuite =>
|
||||
}
|
||||
|
||||
object StoreFixture {
|
||||
val schemaMigrateConfig = SchemaMigrateConfig.defaults
|
||||
|
||||
def memoryDB(dbname: String): JdbcConfig =
|
||||
JdbcConfig(
|
||||
@ -94,7 +97,7 @@ object StoreFixture {
|
||||
xa <- makeXA(ds)
|
||||
cfg = FileRepositoryConfig.Database(64 * 1024)
|
||||
fr = FileRepository[IO](xa, ds, cfg, true)
|
||||
store = new StoreImpl[IO](fr, jdbc, ds, xa)
|
||||
store = new StoreImpl[IO](fr, jdbc, schemaMigrateConfig, ds, xa)
|
||||
_ <- Resource.eval(store.migrate)
|
||||
} yield store
|
||||
|
||||
|
@ -10,7 +10,7 @@ import cats.effect.IO
|
||||
import cats.effect.unsafe.implicits._
|
||||
|
||||
import docspell.logging.TestLoggingConfig
|
||||
import docspell.store.StoreFixture
|
||||
import docspell.store.{SchemaMigrateConfig, StoreFixture}
|
||||
|
||||
import munit.FunSuite
|
||||
|
||||
@ -21,7 +21,7 @@ class H2MigrateTest extends FunSuite with TestLoggingConfig {
|
||||
val ds = StoreFixture.dataSource(jdbc)
|
||||
val result =
|
||||
ds.flatMap(StoreFixture.makeXA).use { xa =>
|
||||
FlywayMigrate[IO](jdbc, xa).run
|
||||
FlywayMigrate[IO](jdbc, SchemaMigrateConfig.defaults, xa).run
|
||||
}
|
||||
|
||||
assert(result.unsafeRunSync().migrationsExecuted > 0)
|
||||
@ -40,7 +40,7 @@ class H2MigrateTest extends FunSuite with TestLoggingConfig {
|
||||
|
||||
val result =
|
||||
ds.flatMap(StoreFixture.makeXA).use { xa =>
|
||||
FlywayMigrate[IO](jdbc, xa).run
|
||||
FlywayMigrate[IO](jdbc, SchemaMigrateConfig.defaults, xa).run
|
||||
}
|
||||
|
||||
result.unsafeRunSync()
|
||||
|
@ -11,7 +11,7 @@ import cats.effect.unsafe.implicits._
|
||||
|
||||
import docspell.common.LenientUri
|
||||
import docspell.logging.TestLoggingConfig
|
||||
import docspell.store.{JdbcConfig, StoreFixture}
|
||||
import docspell.store.{JdbcConfig, SchemaMigrateConfig, StoreFixture}
|
||||
|
||||
import com.dimafeng.testcontainers.MariaDBContainer
|
||||
import com.dimafeng.testcontainers.munit.TestContainerForAll
|
||||
@ -32,7 +32,7 @@ class MariaDbMigrateTest
|
||||
JdbcConfig(LenientUri.unsafe(cnt.jdbcUrl), cnt.dbUsername, cnt.dbPassword)
|
||||
val ds = StoreFixture.dataSource(jdbc)
|
||||
val result = ds.flatMap(StoreFixture.makeXA).use { xa =>
|
||||
FlywayMigrate[IO](jdbc, xa).run
|
||||
FlywayMigrate[IO](jdbc, SchemaMigrateConfig.defaults, xa).run
|
||||
}
|
||||
assert(result.unsafeRunSync().migrationsExecuted > 0)
|
||||
// a second time to apply fixup migrations
|
||||
|
@ -11,7 +11,7 @@ import cats.effect.unsafe.implicits._
|
||||
|
||||
import docspell.common.LenientUri
|
||||
import docspell.logging.TestLoggingConfig
|
||||
import docspell.store.{JdbcConfig, StoreFixture}
|
||||
import docspell.store.{JdbcConfig, SchemaMigrateConfig, StoreFixture}
|
||||
|
||||
import com.dimafeng.testcontainers.PostgreSQLContainer
|
||||
import com.dimafeng.testcontainers.munit.TestContainerForAll
|
||||
@ -34,7 +34,7 @@ class PostgresqlMigrateTest
|
||||
val ds = StoreFixture.dataSource(jdbc)
|
||||
val result =
|
||||
ds.flatMap(StoreFixture.makeXA).use { xa =>
|
||||
FlywayMigrate[IO](jdbc, xa).run
|
||||
FlywayMigrate[IO](jdbc, SchemaMigrateConfig.defaults, xa).run
|
||||
}
|
||||
assert(result.unsafeRunSync().migrationsExecuted > 0)
|
||||
|
||||
|
Reference in New Issue
Block a user