-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display how to use other compatible images such as `pgvector`, `postgis`, `timescaledb`.
- Loading branch information
1 parent
b06885f
commit 329e972
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
modules/postgresql/src/test/java/org/testcontainers/containers/CompatibleImageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.testcontainers.containers; | ||
|
||
import org.junit.Test; | ||
import org.testcontainers.db.AbstractContainerDatabaseTest; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class CompatibleImageTest extends AbstractContainerDatabaseTest { | ||
|
||
@Test | ||
public void pgvector() throws SQLException { | ||
try ( | ||
// pgvectorContainer { | ||
PostgreSQLContainer<?> pgvector = new PostgreSQLContainer<>( | ||
DockerImageName.parse("pgvector/pgvector:pg16").asCompatibleSubstituteFor("postgres") | ||
) | ||
// } | ||
) { | ||
pgvector.start(); | ||
|
||
ResultSet resultSet = performQuery(pgvector, "SELECT 1"); | ||
int resultSetInt = resultSet.getInt(1); | ||
assertThat(resultSetInt).as("A basic SELECT query succeeds").isEqualTo(1); | ||
} | ||
} | ||
|
||
@Test | ||
public void postgis() throws SQLException { | ||
try ( | ||
// postgisContainer { | ||
PostgreSQLContainer<?> postgis = new PostgreSQLContainer<>( | ||
DockerImageName.parse("postgis/postgis:16-3.4-alpine").asCompatibleSubstituteFor("postgres") | ||
) | ||
// } | ||
) { | ||
postgis.start(); | ||
|
||
ResultSet resultSet = performQuery(postgis, "SELECT 1"); | ||
int resultSetInt = resultSet.getInt(1); | ||
assertThat(resultSetInt).as("A basic SELECT query succeeds").isEqualTo(1); | ||
} | ||
} | ||
|
||
@Test | ||
public void timescaledb() throws SQLException { | ||
try ( | ||
// timescaledbContainer { | ||
PostgreSQLContainer<?> timescaledb = new PostgreSQLContainer<>( | ||
DockerImageName.parse("timescale/timescaledb:2.14.2-pg16").asCompatibleSubstituteFor("postgres") | ||
) | ||
// } | ||
) { | ||
timescaledb.start(); | ||
|
||
ResultSet resultSet = performQuery(timescaledb, "SELECT 1"); | ||
int resultSetInt = resultSet.getInt(1); | ||
assertThat(resultSetInt).as("A basic SELECT query succeeds").isEqualTo(1); | ||
} | ||
} | ||
} |