Skip to content

Commit

Permalink
un-ignore unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ktoso committed Aug 25, 2012
1 parent 938b994 commit 5661b3b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.class

*.tmp
*~

Expand Down
14 changes: 1 addition & 13 deletions src/main/java/pl/project13/jgit/DescribeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pl/project13/maven/git/GitCommitIdMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/pl/project13/maven/git/GitCommitIdMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 5661b3b

Please sign in to comment.