-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
junyi.bei
committed
Jun 8, 2016
1 parent
21a82e0
commit 33e2a24
Showing
5 changed files
with
83 additions
and
23 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
48 changes: 48 additions & 0 deletions
48
parallelgit-utils/src/test/java/com/beijunyi/parallelgit/utils/CommitUtilsExistsTest.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,48 @@ | ||
package com.beijunyi.parallelgit.utils; | ||
|
||
import java.io.IOException; | ||
|
||
import com.beijunyi.parallelgit.AbstractParallelGitTest; | ||
import org.eclipse.jgit.lib.ObjectId; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class CommitUtilsExistsTest extends AbstractParallelGitTest { | ||
|
||
@Before | ||
public void setUp() throws IOException { | ||
initRepository(); | ||
} | ||
|
||
@Test | ||
public void testCommitExistsWhenReferencedByCommitId_shouldReturnTrue() throws IOException { | ||
writeSomethingToCache(); | ||
String id = commit().getName(); | ||
assertTrue(CommitUtils.exists(id, repo)); | ||
} | ||
|
||
@Test | ||
public void testHeadCommitExistsWhenReferencedByBranchName_shouldReturnTrue() throws IOException { | ||
writeSomethingToCache(); | ||
commitToBranch("test_branch"); | ||
assertTrue(CommitUtils.exists("test_branch", repo)); | ||
} | ||
|
||
@Test | ||
public void testTagCommitExistsWhenReferencedByTagName_shouldReturnTrue() throws IOException { | ||
writeSomethingToCache(); | ||
ObjectId id = commit(); | ||
TagUtils.tagCommit("test_tag", id, repo); | ||
assertTrue(CommitUtils.exists("test_tag", repo)); | ||
} | ||
|
||
@Test | ||
public void testCommitExistsWhenReferenceDoesNotExist_shouldReturnFalse() throws IOException { | ||
assertFalse(CommitUtils.exists("non_existent_reference", repo)); | ||
} | ||
|
||
|
||
|
||
} |
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