-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExampleTest.java
49 lines (42 loc) · 1.79 KB
/
ExampleTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* SPDX-FileCopyrightText: © 2024 Opencast Software Europe Ltd <https://opencastsoftware.com>
* SPDX-License-Identifier: Apache-2.0
*/
package com.opencastsoftware.pgtap;
import org.flywaydb.core.Flyway;
import org.junit.jupiter.api.BeforeAll;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;
import java.nio.file.Path;
import java.nio.file.Paths;
@Testcontainers
public class ExampleTest extends PgTapTest {
private static final Path pgTapTestPath = Paths.get("src", "test", "sql");
private static final Path pgTapTmpPath = Paths.get("/tmp", "pgtap", "sql");
private static final DockerImageName containerName = DockerImageName
.parse("ghcr.io/opencastsoftware/timescaledb-with-pgtap:2.13.0-pg15")
.asCompatibleSubstituteFor("postgres");
@Container
private static final PostgreSQLContainer<?> timescaleDb = new PostgreSQLContainer<>(containerName)
.waitingFor(Wait.forListeningPort())
.withCopyFileToContainer(
MountableFile.forHostPath(pgTapTestPath.toAbsolutePath()),
pgTapTmpPath.toString()
);
public ExampleTest() {
super(timescaleDb, pgTapTestPath, pgTapTmpPath);
}
@BeforeAll
public static void runFlyway() {
Flyway.configure()
.locations("classpath:db/migration")
.dataSource(timescaleDb.getJdbcUrl(), timescaleDb.getUsername(), timescaleDb.getPassword())
.defaultSchema("test")
.load()
.migrate();
}
}