1
package org.testcontainers.jdbc;
4
import org.testcontainers.containers.Container;
5
import org.testcontainers.containers.JdbcDatabaseContainer;
7
import java.sql.Connection;
8
import java.sql.DriverManager;
10
import static org.assertj.core.api.Assertions.assertThat;
13
* This test belongs in the jdbc module, as it is focused on testing the behaviour of {@link org.testcontainers.containers.JdbcDatabaseContainer}.
14
* However, the need to use the {@link org.testcontainers.containers.PostgreSQLContainerProvider} (due to the jdbc:tc:postgresql) URL forces it to live here in
15
* the mysql module, to avoid circular dependencies.
16
* TODO: Move to the jdbc module and either (a) implement a barebones {@link org.testcontainers.containers.JdbcDatabaseContainerProvider} for testing, or (b) refactor into a unit test.
18
public class DatabaseDriverTmpfsTest {
21
public void testDatabaseHasTmpFsViaConnectionString() throws Exception {
22
final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename?TC_TMPFS=/testtmpfs:rw";
23
try (Connection ignored = DriverManager.getConnection(jdbcUrl)) {
24
JdbcDatabaseContainer<?> container = ContainerDatabaseDriver.getContainer(jdbcUrl);
25
// check file doesn't exist
26
String path = "/testtmpfs/test.file";
27
Container.ExecResult execResult = container.execInContainer("ls", path);
28
assertThat(execResult.getExitCode())
29
.as("tmpfs inside container doesn't have file that doesn't exist")
31
// touch && check file does exist
32
container.execInContainer("touch", path);
33
execResult = container.execInContainer("ls", path);
34
assertThat(execResult.getExitCode()).as("tmpfs inside container has file that does exist").isZero();