Hello, thank for this work. I would like to offer a tip that I use in my project -- instead of using helper code to manually run .sql
files for DB creation, you can copy the file into the container and have it automatically run to create the DB + rows:
// File is /src/test/resources/test-database-setup/init-mysql.sql
val mySQLContainer = MySQLContainer("mysql:8.0.28")
.withInitScript("test-database-setup/init-mysql.sql")
// Oracle requires this workaround
val oracleContainer = OracleContainer("gvenzl/oracle-xe:21.3.0-slim")
.withCopyFileToContainer(
MountableFile.forClasspathResource("test-database-setup/init-oracle.sql"),
"/container-entrypoint-startdb.d/init.sql"
)
val postgresContainer = PostgreSQLContainer("postgres:14")
.withInitScript("test-database-setup/init-postgres.sql")
I am not sure if this works with classpath files inside of a jar though, maybe you need classpath://
as file URI or something?