diff options
author | Tomasz Zarna <Tomasz.Zarna@pl.ibm.com> | 2011-08-17 15:12:07 +0200 |
---|---|---|
committer | Chris Aniszczyk <zx@twitter.com> | 2011-08-21 13:18:52 -0700 |
commit | 5f787bfd628cab29e262a67da821579b420466f8 (patch) | |
tree | 30069c3bd6b66d02f08a82561e816847e8f25cef /org.eclipse.jgit.test/tst | |
parent | 148595fb54265265a5409339d168ee2b8e2bfed1 (diff) | |
download | jgit-5f787bfd628cab29e262a67da821579b420466f8.tar.gz jgit-5f787bfd628cab29e262a67da821579b420466f8.zip |
Add DeleteTagCommand to JGit API
Bug: 353226
Change-Id: I54ae237cab792742333a249eb5a774d5e1775af8
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-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()); + } + } |