Skip to content

Commit 83d36d8

Browse files
committed
removed runningTests variable and special treatment of tests in production code
1 parent 30bbc78 commit 83d36d8

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/main/java/pl/project13/maven/git/GitCommitIdMojo.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,6 @@ public class GitCommitIdMojo extends AbstractMojo {
366366
*/
367367
private Properties properties;
368368

369-
// TODO remove this
370-
boolean runningTests = false;
371-
372369
@NotNull
373370
private final VerboseLog log = new VerboseLogger(this, true);
374371

@@ -539,10 +536,8 @@ private void appendPropertiesToReactorProjects(@NotNull Properties properties, @
539536
private Properties initProperties() throws MojoExecutionException {
540537
if (generateGitPropertiesFile) {
541538
return properties = new Properties();
542-
} else if (!runningTests) {
543-
return properties = project.getProperties();
544539
} else {
545-
return properties = new Properties(); // that's ok for unit tests
540+
return properties = project.getProperties();
546541
}
547542
}
548543

src/test/java/pl/project13/maven/git/GitCommitIdMojoDirtyFilesTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ public void testDetectCleanWorkingDirectory() throws Exception {
3838
String prefix = "git";
3939
int abbrevLength = 7;
4040
String dateFormat = "dd.MM.yyyy '@' HH:mm:ss z";
41-
boolean verbose = true;
4241

4342
GitCommitIdMojo mojo = new GitCommitIdMojo();
4443
mojo.setDotGitDirectory(dotGitDirectory);
4544
mojo.setPrefix(prefix);
4645
mojo.setAbbrevLength(abbrevLength);
4746
mojo.setDateFormat(dateFormat);
48-
mojo.setVerbose(verbose);
47+
mojo.setVerbose(true);
4948
mojo.useNativeGit(false);
5049
mojo.setGitDescribe(gitDescribeConfig);
5150

5251

53-
mojo.runningTests = true;
5452
mojo.project = mock(MavenProject.class, RETURNS_MOCKS);
53+
Properties props = new Properties();
54+
when(mojo.project.getProperties()).thenReturn(props);
5555
when(mojo.project.getPackaging()).thenReturn("jar");
5656

5757
mojo.execute();
@@ -70,20 +70,20 @@ public void testDetectDirtyWorkingDirectory() throws Exception {
7070
String prefix = "git";
7171
int abbrevLength = 7;
7272
String dateFormat = "dd.MM.yyyy '@' HH:mm:ss z";
73-
boolean verbose = true;
7473

7574
GitCommitIdMojo mojo = new GitCommitIdMojo();
7675
mojo.setDotGitDirectory(dotGitDirectory);
7776
mojo.setPrefix(prefix);
7877
mojo.setAbbrevLength(abbrevLength);
7978
mojo.setDateFormat(dateFormat);
80-
mojo.setVerbose(verbose);
79+
mojo.setVerbose(true);
8180
mojo.useNativeGit(false);
8281
mojo.setGitDescribe(gitDescribeConfig);
8382

8483

85-
mojo.runningTests = true;
8684
mojo.project = mock(MavenProject.class, RETURNS_MOCKS);
85+
Properties props = new Properties();
86+
when(mojo.project.getProperties()).thenReturn(props);
8787
when(mojo.project.getPackaging()).thenReturn("jar");
8888

8989
mojo.execute();

src/test/java/pl/project13/maven/git/GitCommitIdMojoTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* I'm not a big fan of this test - let's move to integration test from now on.
3737
*
3838
*/
39-
// todo remove this test in favor of complete intgration tests
39+
// todo remove this test in favor of complete integration tests
4040
public class GitCommitIdMojoTest {
4141

4242
GitCommitIdMojo mojo;
@@ -63,8 +63,9 @@ public void setUp() throws Exception {
6363
mojo.setCommitIdGenerationMode("full");
6464

6565

66-
mojo.runningTests = true;
6766
mojo.project = mock(MavenProject.class, RETURNS_MOCKS);
67+
Properties props = new Properties();
68+
when(mojo.project.getProperties()).thenReturn(props);
6869
when(mojo.project.getPackaging()).thenReturn("jar");
6970
when(mojo.project.getVersion()).thenReturn("3.3-SNAPSHOT");
7071

0 commit comments

Comments
 (0)