Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

un-ignore unit test

  • Loading branch information...
commit 5661b3b58aac4907dd6c3350cd60f005400c68c6 1 parent 938b994
@ktoso authored
View
1  .gitignore
@@ -1,5 +1,4 @@
*.class
-
*.tmp
*~
View
14 src/main/java/pl/project13/jgit/DescribeCommand.java
@@ -246,11 +246,7 @@ private DescribeResult createDescribeResult(ObjectId headCommitId, boolean dirty
}
}
- String applyAbbrev(ObjectId commitId) {
- return commitId.getName().substring(0, abbrev);
- }
-
- private boolean foundZeroTags(Map<ObjectId, String> tags) {
+ private static boolean foundZeroTags(Map<ObjectId, String> tags) {
return tags.isEmpty();
}
@@ -259,14 +255,6 @@ boolean findDirtyState(Repository repo) throws GitAPIException {
Git git = Git.wrap(repo);
Status status = git.status().call();
-// System.out.println("add = " + status.getAdded());
-// System.out.println("chng = " + status.getChanged());
-// System.out.println("conf = " + status.getConflicting());
-// System.out.println("miss = " + status.getMissing());
-// System.out.println("mod = " + status.getModified());
-// System.out.println("rm = " + status.getRemoved());
-// System.out.println("un = " + status.getUntracked());
-
boolean isDirty = !status.isClean();
log("Repo is in dirty state = [%s] ", isDirty);
View
4 src/main/java/pl/project13/maven/git/GitCommitIdMojo.java
@@ -17,6 +17,7 @@
package pl.project13.maven.git;
+import com.google.common.annotations.VisibleForTesting;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
@@ -317,7 +318,8 @@ void loadGitData(Properties properties) throws IOException, MojoExecutionExcepti
}
}
- private void putGitDescribe(Properties properties, Repository repository) throws MojoExecutionException {
+ @VisibleForTesting
+ void putGitDescribe(Properties properties, Repository repository) throws MojoExecutionException {
try {
DescribeResult describeResult = DescribeCommand
.on(repository)
View
10 src/test/java/pl/project13/maven/git/GitCommitIdMojoTest.java
@@ -18,8 +18,8 @@
package pl.project13.maven.git;
import org.apache.maven.project.MavenProject;
+import org.eclipse.jgit.lib.Repository;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import java.io.File;
@@ -29,11 +29,10 @@
import static org.mockito.Mockito.*;
/**
- * Date: 2/13/11
+ * I'm not a big fan of this test - let's move to integration test from now on.
*
* @author <a href="mailto:konrad.malawski@project13.pl">Konrad 'ktoso' Malawski</a>
*/
-@Ignore("Makes things difficult to evolve, go for integration tests instead")
public class GitCommitIdMojoTest {
GitCommitIdMojo mojo;
@@ -49,10 +48,13 @@ public void setUp() throws Exception {
mojo.runningTests = true;
mojo.project = mock(MavenProject.class, RETURNS_MOCKS);
when(mojo.project.getPackaging()).thenReturn("jar");
+
+ mojo = spy(mojo);
+ doNothing().when(mojo).putGitDescribe(any(Properties.class), any(Repository.class));
}
@Test
- public void testExecute() throws Exception {
+ public void shouldIncludeExpectedProperties() throws Exception {
mojo.execute();
Properties properties = mojo.getProperties();
Please sign in to comment.
Something went wrong with that request. Please try again.