-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #1482: SkipPom is ignored by push goal
Signed-off-by: Rohan Kumar <[email protected]>
- Loading branch information
1 parent
dd086ee
commit 1a8a9ad
Showing
5 changed files
with
125 additions
and
8 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
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
112 changes: 112 additions & 0 deletions
112
src/test/java/io/fabric8/maven/docker/PushMojoTest.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,112 @@ | ||
package io.fabric8.maven.docker; | ||
|
||
import io.fabric8.maven.docker.access.DockerAccessException; | ||
import io.fabric8.maven.docker.config.ImageConfiguration; | ||
import io.fabric8.maven.docker.service.RegistryService; | ||
import mockit.Deencapsulation; | ||
import mockit.Mocked; | ||
import mockit.Tested; | ||
import mockit.Verifications; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
|
||
public class PushMojoTest extends BaseMojoTest { | ||
@Tested | ||
private PushMojo pushMojo; | ||
|
||
@Mocked | ||
private RegistryService registryService; | ||
|
||
@Test | ||
public void executeInternal_whenSkipPomEnabledInPomPackaging_thenImagePushSkipped() throws MojoExecutionException, IOException { | ||
Deencapsulation.setField(serviceHub, "registryService", registryService); | ||
givenMavenProject(pushMojo); | ||
givenPackaging("pom"); | ||
givenSkipPom(true); | ||
|
||
whenMojoExecutes(); | ||
|
||
thenImageNotPushed(); | ||
} | ||
|
||
@Test | ||
public void executeInternal_whenPomPackaging_thenImageIsPushed() throws MojoExecutionException, IOException { | ||
Deencapsulation.setField(serviceHub, "registryService", registryService); | ||
givenMavenProject(pushMojo); | ||
givenPackaging("pom"); | ||
givenSkipPom(false); | ||
|
||
whenMojoExecutes(); | ||
|
||
thenImagePushed(); | ||
} | ||
|
||
@Test | ||
public void executeInternal_whenJarPackaging_thenImageIsPushed() throws MojoExecutionException, IOException { | ||
Deencapsulation.setField(serviceHub, "registryService", registryService); | ||
givenMavenProject(pushMojo); | ||
givenPackaging("jar"); | ||
|
||
whenMojoExecutes(); | ||
|
||
thenImagePushed(); | ||
} | ||
|
||
@Test | ||
public void executeInternal_whenSkipEnabled_thenImageIsPushed() throws MojoExecutionException, IOException { | ||
Deencapsulation.setField(serviceHub, "registryService", registryService); | ||
givenMavenProject(pushMojo); | ||
givenPackaging("jar"); | ||
givenSkipPush(true); | ||
|
||
whenMojoExecutes(); | ||
|
||
thenImageNotPushed(); | ||
} | ||
|
||
@Test | ||
public void executeInternal_whenSkipDisabled_thenImageIsPushed() throws MojoExecutionException, IOException { | ||
Deencapsulation.setField(serviceHub, "registryService", registryService); | ||
givenMavenProject(pushMojo); | ||
givenPackaging("jar"); | ||
givenSkipPush(false); | ||
|
||
whenMojoExecutes(); | ||
|
||
thenImagePushed(); | ||
} | ||
|
||
private void thenImagePushed() throws MojoExecutionException, DockerAccessException { | ||
new Verifications() {{ | ||
registryService.pushImages((Collection<ImageConfiguration>) any, anyInt, (RegistryService.RegistryConfig)any, anyBoolean); | ||
times = 1; | ||
}}; | ||
} | ||
|
||
private void thenImageNotPushed() throws DockerAccessException, MojoExecutionException { | ||
new Verifications() {{ | ||
registryService.pushImages((Collection<ImageConfiguration>) any, anyInt, (RegistryService.RegistryConfig)any, anyBoolean); | ||
times = 0; | ||
}}; | ||
} | ||
|
||
private void whenMojoExecutes() throws IOException, MojoExecutionException { | ||
pushMojo.executeInternal(serviceHub); | ||
} | ||
|
||
private void givenPackaging(String packaging) { | ||
Deencapsulation.setField(pushMojo, "packaging", packaging); | ||
} | ||
|
||
private void givenSkipPom(boolean skipPom) { | ||
Deencapsulation.setField(pushMojo, "skipPom", skipPom); | ||
} | ||
|
||
private void givenSkipPush(boolean skip) { | ||
Deencapsulation.setField(pushMojo, "skipPush", skip); | ||
} | ||
|
||
} |