Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable copyFileToContainer feature during container startup (#742)
- Loading branch information
1 parent
577b509
commit 22cab1f
Showing
4 changed files
with
64 additions
and
2 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
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
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
25 changes: 25 additions & 0 deletions
25
core/src/test/java/org/testcontainers/junit/CopyFileToContainerTest.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,25 @@ | ||
package org.testcontainers.junit; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.utility.MountableFile; | ||
import java.io.IOException; | ||
|
||
public class CopyFileToContainerTest { | ||
private static String containerPath = "/tmp"; | ||
private static String fileName = "test-resource.txt"; | ||
|
||
@Test | ||
public void checkFileCopied() throws IOException, InterruptedException { | ||
try( | ||
GenericContainer container = new GenericContainer("alpine:latest") | ||
.withCommand("sleep","3000") | ||
.withCopyFileToContainer(MountableFile.forClasspathResource("/mappable-resource/"), containerPath) | ||
) { | ||
container.start(); | ||
String filesList = container.execInContainer("ls","/tmp/mappable-resource").getStdout(); | ||
Assert.assertTrue(filesList.contains(fileName)); | ||
} | ||
} | ||
} |