-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
16 deletions.
There are no files selected for viewing
20 changes: 4 additions & 16 deletions
20
modules/jdbc-test/src/test/java/org/testcontainers/jdbc/DatabaseDriverTmpfsTest.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 |
---|---|---|
@@ -1,43 +1,31 @@ | ||
package org.testcontainers.jdbc; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.testcontainers.containers.Container; | ||
import org.testcontainers.containers.JdbcDatabaseContainer; | ||
import org.testcontainers.testsupport.Flaky; | ||
import org.testcontainers.testsupport.FlakyTestJUnit4RetryRule; | ||
|
||
import java.io.IOException; | ||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
import static org.rnorth.visibleassertions.VisibleAssertions.assertEquals; | ||
import static org.rnorth.visibleassertions.VisibleAssertions.assertNotEquals; | ||
|
||
public class DatabaseDriverTmpfsTest { | ||
|
||
@Rule | ||
public FlakyTestJUnit4RetryRule retry = new FlakyTestJUnit4RetryRule(); | ||
|
||
@Test | ||
@Flaky(githubIssueUrl = "https://github.com/testcontainers/testcontainers-java/issues/1687", reviewDate = "2020-03-01") | ||
public void tmpfs() throws IOException, InterruptedException, SQLException { | ||
public void testDatabaseHasTmpFsViaConnectionString() throws Exception { | ||
final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename?TC_TMPFS=/testtmpfs:rw"; | ||
try (Connection ignored = DriverManager.getConnection(jdbcUrl)) { | ||
|
||
JdbcDatabaseContainer<?> container = ContainerDatabaseDriver.getContainer(jdbcUrl); | ||
// check file doesn't exist | ||
String path = "/testtmpfs/test.file"; | ||
Container.ExecResult execResult = container.execInContainer("ls", path); | ||
assertEquals("tmpfs inside container works fine", execResult.getStderr(), | ||
"ls: cannot access '/testtmpfs/test.file': No such file or directory\n"); | ||
assertNotEquals("tmpfs inside container doesn't have file that doesn't exist", 0, execResult.getExitCode()); | ||
// touch && check file does exist | ||
container.execInContainer("touch", path); | ||
execResult = container.execInContainer("ls", path); | ||
assertEquals("tmpfs inside container works fine", execResult.getStdout(), path + "\n"); | ||
assertEquals("tmpfs inside container has file that does exist", 0, execResult.getExitCode()); | ||
} | ||
|
||
} | ||
|
||
|
||
} |