diff options
author | Chris Aniszczyk <caniszczyk@gmail.com> | 2011-08-21 16:24:23 -0400 |
---|---|---|
committer | Code Review <codereview-daemon@eclipse.org> | 2011-08-21 16:24:23 -0400 |
commit | bd691f162c32cd9e9834e1d8a2baef99c4eac09b (patch) | |
tree | 1ded58d0ca04f7454a45d9711ef57b55392e19a2 /org.eclipse.jgit.test | |
parent | 12bb76380fa48c47ef00565f9af20df9df0871f7 (diff) | |
parent | 5f787bfd628cab29e262a67da821579b420466f8 (diff) | |
download | jgit-bd691f162c32cd9e9834e1d8a2baef99c4eac09b.tar.gz jgit-bd691f162c32cd9e9834e1d8a2baef99c4eac09b.zip |
Merge "Add DeleteTagCommand to JGit API"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java index d4da87ab00..1db0381d0b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java @@ -45,6 +45,8 @@ package org.eclipse.jgit.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import java.util.List; + import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; import org.eclipse.jgit.api.errors.InvalidTagNameException; import org.eclipse.jgit.api.errors.JGitInternalException; @@ -52,6 +54,8 @@ import org.eclipse.jgit.api.errors.NoHeadException; import org.eclipse.jgit.api.errors.NoMessageException; import org.eclipse.jgit.api.errors.WrongRepositoryStateException; import org.eclipse.jgit.errors.UnmergedPathException; +import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevTag; @@ -128,4 +132,69 @@ public class TagCommandTest extends RepositoryTestCase { } } + @Test + public void testDelete() throws Exception { + Git git = new Git(db); + git.commit().setMessage("initial commit").call(); + RevTag tag = git.tag().setName("tag").call(); + assertEquals(1, db.getTags().size()); + + List<String> deleted = git.tagDelete().setTags(tag.getTagName()) + .call(); + assertEquals(1, deleted.size()); + assertEquals(tag.getTagName(), + Repository.shortenRefName(deleted.get(0))); + assertEquals(0, db.getTags().size()); + + RevTag tag1 = git.tag().setName("tag1").call(); + RevTag tag2 = git.tag().setName("tag2").call(); + assertEquals(2, db.getTags().size()); + deleted = git.tagDelete() + .setTags(tag1.getTagName(), tag2.getTagName()).call(); + assertEquals(2, deleted.size()); + assertEquals(0, db.getTags().size()); + } + + @Test + public void testDeleteFullName() throws Exception { + Git git = new Git(db); + git.commit().setMessage("initial commit").call(); + RevTag tag = git.tag().setName("tag").call(); + assertEquals(1, db.getTags().size()); + + List<String> deleted = git.tagDelete() + .setTags(Constants.R_TAGS + tag.getTagName()).call(); + assertEquals(1, deleted.size()); + assertEquals(Constants.R_TAGS + tag.getTagName(), deleted.get(0)); + assertEquals(0, db.getTags().size()); + } + + @Test + public void testDeleteEmptyTagNames() throws Exception { + Git git = new Git(db); + git.commit().setMessage("initial commit").call(); + + List<String> deleted = git.tagDelete().setTags().call(); + assertEquals(0, deleted.size()); + } + + @Test + public void testDeleteNonExisting() throws Exception { + Git git = new Git(db); + git.commit().setMessage("initial commit").call(); + + List<String> deleted = git.tagDelete().setTags("tag").call(); + assertEquals(0, deleted.size()); + } + + @Test + public void testDeleteBadName() throws Exception { + Git git = new Git(db); + git.commit().setMessage("initial commit").call(); + + List<String> deleted = git.tagDelete().setTags("bad~tag~name") + .call(); + assertEquals(0, deleted.size()); + } + } |