Skip to content

Commit

Permalink
Tests for copy goal when using temporary container.
Browse files Browse the repository at this point in the history
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
  • Loading branch information
mabrarov committed Dec 3, 2020
1 parent 9cc4c7a commit 2b235ea
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 18 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<argLine>
-javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
</argLine>
<workingDirectory>${project.build.testOutputDirectory}</workingDirectory>
</configuration>
</plugin>

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/fabric8/maven/docker/CopyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ private void copy(DockerAccess dockerAccess, ArchiveService archiveService, Stri
for (CopyConfiguration.Entry copyEntry : copyEntries) {
String containerPath = copyEntry.getContainerPath();
if (containerPath == null) {
log.error("containerPath of copy goal entry for %s image is not specified", containerId, imageName);
log.error("containerPath of copy goal entry for %s image is not specified", imageName);
throw new IllegalArgumentException("containerPath should be specified");
}
File hostDirectory = getHostDirectory(copyEntry.getHostDirectory());
log.info("Copying %s from %s container into %s host directory", containerPath, containerId, hostDirectory);
log.info("Copying %s from %s container into %s host directory", containerPath, containerId,
hostDirectory.getAbsolutePath());
Files.createDirectories(hostDirectory.toPath());
try (FileRemover fileRemover = new FileRemover(log)) {
File archiveFile = Files.createTempFile(TEMP_ARCHIVE_FILE_PREFIX, TEMP_ARCHIVE_FILE_SUFFIX).toFile();
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/io/fabric8/maven/docker/BaseMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class BaseMojoTest {
protected String projectGroupId;
protected String projectArtifactId;
protected String projectVersion;
protected String projectBaseDirectory;
protected String projectBuildDirectory;

protected GavLabel projectGavLabel;
Expand Down Expand Up @@ -158,6 +159,7 @@ protected void givenMavenProject(AbstractDockerMojo mojo) {
projectGroupId = "mock.group";
projectArtifactId = "mock-artifact";
projectVersion = "1.0.0-MOCK";
projectBaseDirectory = "mock-base";
projectBuildDirectory = "mock-target";
projectGavLabel = new GavLabel(projectGroupId, projectArtifactId, projectVersion);

Expand All @@ -167,6 +169,7 @@ protected void givenMavenProject(AbstractDockerMojo mojo) {
mavenProject.getGroupId(); result = projectGroupId; minTimes = 0;
mavenProject.getArtifactId(); result = projectArtifactId; minTimes = 0;
mavenProject.getVersion(); result = projectVersion; minTimes = 0;
mavenProject.getBasedir(); result = projectBaseDirectory; minTimes = 0;
mavenBuild.getDirectory(); result = projectBuildDirectory; minTimes = 0;
}};

Expand Down
Loading

0 comments on commit 2b235ea

Please sign in to comment.