Skip to content

Commit

Permalink
Refactor postgres testcontainers base class
Browse files Browse the repository at this point in the history
Due to the issue testcontainers/testcontainers-java#2352 PostgresTestContainer class had been refactored to stop the creation of a new container before each test.
  • Loading branch information
Berchris Requiao committed Aug 4, 2021
1 parent d904521 commit b21ebb5
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@
import static java.lang.String.format;
import static java.util.Collections.singletonMap;

@Testcontainers
public abstract class PostgresTestContainer {

private static final DockerImageName postgresImage =
DockerImageName.parse("postgres").withTag("13.3-alpine");

@Container
private static final PostgreSQLContainer<?> postgresContainer =
new PostgreSQLContainer<>(postgresImage)
.withTmpFs(singletonMap("/test_tmpfs", "rw"))
.withReuse(true);

// https://github.com/testcontainers/testcontainers-java/issues/2352
static {
postgresContainer.start();
}

@DynamicPropertySource
private static void setDatasourceProperties(DynamicPropertyRegistry registry) {
// Liquibase DataSource
Expand Down

0 comments on commit b21ebb5

Please sign in to comment.