Skip to content

Commit

Permalink
Add test for [JENKINS-30589] - getRemoteReferences return empty map
Browse files Browse the repository at this point in the history
JGit correctly returns an empty map when remote references are not
found, while CliGitAPIImpl threw an exception.
  • Loading branch information
MarkEWaite committed Nov 17, 2017
1 parent 1800763 commit a59623c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/test/java/org/jenkinsci/plugins/gitclient/GitClientTest.java
Expand Up @@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -866,6 +867,27 @@ public void testGetRemoteReferences() throws Exception {
assertEquals(expResult, result);
}

@Issue("JENKINS-30589")
@Test
public void testGetRemoteReferences_ReturnsEmptyMapIfNoTags() throws Exception {
String url = repoRoot.getAbsolutePath();
String pattern = "**";
boolean headsOnly = false;
boolean tagsOnly = true;
Map<String, ObjectId> result = gitClient.getRemoteReferences(url, pattern, headsOnly, tagsOnly);
assertThat(result, is(Collections.EMPTY_MAP));
}

@Test
public void testGetRemoteReferencesNonExistingPattern() throws Exception {
String url = repoRoot.getAbsolutePath();
String pattern = "non-existent-name";
boolean headsOnly = false;
boolean tagsOnly = false;
Map<String, ObjectId> result = gitClient.getRemoteReferences(url, pattern, headsOnly, tagsOnly);
assertThat(result, is(Collections.EMPTY_MAP));
}

@Test
public void testRevParse() throws Exception {
ObjectId commitA = commitOneFile();
Expand Down

0 comments on commit a59623c

Please sign in to comment.