Skip to content

Commit fe9f04f

Browse files
committed
More Coverage.
1 parent eba3a88 commit fe9f04f

File tree

3 files changed

+138
-6
lines changed

3 files changed

+138
-6
lines changed

src/main/java/com/e_gineering/maven/gitflowhelper/RetargetDeployMojo.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ protected void execute(final GitBranchInfo gitBranchInfo) throws MojoExecutionEx
2525
project.setReleaseArtifactRepository(getDeploymentRepository(releaseDeploymentRepository));
2626
break;
2727
}
28-
case RELEASE: {
29-
getLog().info("Setting release artifact repository to: [" + stageDeploymentRepository + "]");
30-
project.setSnapshotArtifactRepository(null);
31-
project.setReleaseArtifactRepository(getDeploymentRepository(stageDeploymentRepository));
32-
break;
33-
}
28+
case RELEASE:
3429
case HOTFIX: {
3530
getLog().info("Setting release artifact repository to: [" + stageDeploymentRepository + "]");
3631
project.setSnapshotArtifactRepository(null);

src/test/java/com/e_gineering/maven/gitflowhelper/EnforceVersionsIT.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,30 @@ public void supportsStartswithMismatch() throws Exception {
6666
}
6767
}
6868

69+
@Test
70+
public void featureAllowsSnapshot() throws Exception {
71+
Verifier verifier = createVerifier("/project-stub", "origin/feature/aFeatureBranch", "1.0.0-SNAPSHOT");
72+
73+
try {
74+
verifier.executeGoal("gitflow-helper:enforce-versions");
75+
verifier.verifyErrorFreeLog();
76+
} finally {
77+
verifier.resetStreams();
78+
}
79+
}
80+
81+
@Test
82+
public void featureAllowsNonSnapshot() throws Exception {
83+
Verifier verifier = createVerifier("/project-stub", "origin/feature/aFeatureBranch", "1.0.0");
84+
85+
try {
86+
verifier.executeGoal("gitflow-helper:enforce-versions");
87+
verifier.verifyErrorFreeLog();
88+
} finally {
89+
verifier.resetStreams();
90+
}
91+
}
92+
6993
@Test
7094
public void dependencySuccesses() throws Exception {
7195
// Stage the repository with version 1.0.0 of the stub.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package com.e_gineering.maven.gitflowhelper;
2+
3+
import org.apache.maven.it.Verifier;
4+
import org.junit.Assert;
5+
import org.junit.Test;
6+
import org.junit.runner.RunWith;
7+
import org.junit.runners.BlockJUnit4ClassRunner;
8+
9+
import java.io.File;
10+
11+
@RunWith(BlockJUnit4ClassRunner.class)
12+
public class RetargetDeployIT extends AbstractIntegrationTest {
13+
14+
@Test
15+
public void devTargetsSnapshot() throws Exception {
16+
Verifier verifier = createVerifier("/project-stub", "origin/develop", "3.0.0-SNAPSHOT");
17+
18+
verifier.executeGoal("deploy");
19+
20+
verifier.verifyErrorFreeLog();
21+
verifier.resetStreams();
22+
23+
// Ensure the file exists in the repo.
24+
File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/snapshots/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.0.0-SNAPSHOT");
25+
Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0);
26+
}
27+
28+
@Test
29+
public void releaseTargetsTest() throws Exception {
30+
Verifier verifier = createVerifier("/project-stub", "origin/release/3.1.0", "3.1.0");
31+
32+
verifier.executeGoal("deploy");
33+
34+
verifier.verifyErrorFreeLog();
35+
verifier.resetStreams();
36+
37+
// Ensure the file exists in the repo.
38+
File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/test-releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.1.0");
39+
Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0);
40+
}
41+
42+
@Test
43+
public void hotfixTargetsTest() throws Exception {
44+
Verifier verifier = createVerifier("/project-stub", "origin/hotfix/3.1.5", "3.1.5");
45+
46+
verifier.executeGoal("deploy");
47+
48+
verifier.verifyErrorFreeLog();
49+
verifier.resetStreams();
50+
51+
// Ensure the file exists in the repo.
52+
File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/test-releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.1.5");
53+
Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0);
54+
}
55+
56+
@Test
57+
public void supportTargetsReleases() throws Exception {
58+
// Deploy a hotfix to the test-releases.
59+
Verifier verifier = createVerifier("/project-stub", "origin/hotfix/3.2.1", "3.2.1");
60+
verifier.executeGoal("deploy");
61+
verifier.verifyErrorFreeLog();
62+
verifier.resetStreams();
63+
64+
File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/test-releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.2.1");
65+
Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0);
66+
67+
// Promote with the support branch
68+
verifier = createVerifier("/project-stub", "origin/support/3.2", "3.2.1");
69+
verifier.executeGoal("deploy");
70+
71+
verifier.verifyErrorFreeLog();
72+
verifier.resetStreams();
73+
74+
// Ensure the file exists in the repo.
75+
artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.2.1");
76+
Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0);
77+
}
78+
79+
@Test
80+
public void masterTargetsReleases() throws Exception {
81+
// Deploy a hotfix to the test-releases.
82+
Verifier verifier = createVerifier("/project-stub", "origin/release/3.3.0", "3.3.0");
83+
verifier.executeGoal("deploy");
84+
verifier.verifyErrorFreeLog();
85+
verifier.resetStreams();
86+
87+
File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/test-releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.3.0");
88+
Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0);
89+
90+
// Promote with the support branch
91+
verifier = createVerifier("/project-stub", "origin/master", "3.3.0");
92+
verifier.executeGoal("deploy");
93+
94+
verifier.verifyErrorFreeLog();
95+
verifier.resetStreams();
96+
97+
// Ensure the file exists in the repo.
98+
artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.3.0");
99+
Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0);
100+
}
101+
102+
@Test
103+
public void othersUnsetRepos() throws Exception {
104+
// Deploy a hotfix to the test-releases.
105+
Verifier verifier = createVerifier("/project-stub", "feature/undeployable", "3.5.0-SNAPSHOT");
106+
try {
107+
verifier.executeGoal("deploy");
108+
verifier.verifyTextInLog("[INFO] Skipping artifact deployment");
109+
} finally {
110+
verifier.resetStreams();
111+
}
112+
}
113+
}

0 commit comments

Comments
 (0)