AC
Size: a a a
AC
Oℕ
C
AM
AM
AD
λ
AM
AD
λ
P
Α
munit + testcontainers-(munit|postgres)
И написал в итоге все так:class BuildRepoImplSpec extends FunSuite with TestContainerForAll with Donors {
override val containerDef: ContainerDef = PostgreSQLContainer.Def()
implicit val executionContext: ExecutionContext =
ExecutionContext.fromExecutor(
Executors.newFixedThreadPool(10)
)
override def afterContainersStart(container: containerDef.Container): Unit = {
val postgresContainer = container.asInstanceOf[PostgreSQLContainer]
Main.migrate(
DB(
url = postgresContainer.jdbcUrl,
driver = postgresContainer.driverClassName,
user = postgresContainer.username,
password = postgresContainer.password
)
).unsafeRunSync()
}
test("create and retrieve the build") {
withContainers { container =>
val postgresContainer = container.asInstanceOf[PostgreSQLContainer] // Пришлось так делать
val db =
Database.forURL(
url = postgresContainer.jdbcUrl,
user = postgresContainer.username,
driver = postgresContainer.driverClassName,
password = postgresContainer.password
)
...
Потому что тип containerDef.Container является всего лишь:type Container <: Startable with StoppableИ если не кастовать то фиг достанешь параметры для создания транзактора
ΛВ
ΛВ
Α
sbt testΛВ
ΛВ
ΛВ
Α
ЮБ