Skip to content

Commit

Permalink
[JENKINS-48035] negative tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rsandell committed Dec 12, 2017
1 parent 361e6d1 commit 0203fb2
Showing 1 changed file with 26 additions and 0 deletions.
Expand Up @@ -38,6 +38,7 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.ExtensionList;
import hudson.model.Action;
import hudson.model.FreeStyleProject;
import hudson.model.Item;
import hudson.model.TaskListener;
import hudson.model.User;
Expand Down Expand Up @@ -178,6 +179,31 @@ public void testGitHubRepositoryNameContributor() throws IOException {
)));
}

@Test
@Issue("JENKINS-48035")
public void testGitHubRepositoryNameContributor_When_not_GitHub() throws IOException {
WorkflowMultiBranchProject job = r.createProject(WorkflowMultiBranchProject.class);
job.setSourcesList(Arrays.asList(new BranchSource(new GitSCMSource("file://tmp/something"))));
Collection<GitHubRepositoryName> names = GitHubRepositoryNameContributor.parseAssociatedNames(job);
assertThat(names, Matchers.<GitHubRepositoryName>empty());
//And specifically...
names = new ArrayList<>();
ExtensionList.lookup(GitHubRepositoryNameContributor.class).get(GitHubSCMSourceRepositoryNameContributor.class).parseAssociatedNames(job, names);
assertThat(names, Matchers.<GitHubRepositoryName>empty());
}

@Test
@Issue("JENKINS-48035")
public void testGitHubRepositoryNameContributor_When_not_MultiBranch() throws IOException {
FreeStyleProject job = r.createProject(FreeStyleProject.class);
Collection<GitHubRepositoryName> names = GitHubRepositoryNameContributor.parseAssociatedNames((Item) job);
assertThat(names, Matchers.<GitHubRepositoryName>empty());
//And specifically...
names = new ArrayList<>();
ExtensionList.lookup(GitHubRepositoryNameContributor.class).get(GitHubSCMSourceRepositoryNameContributor.class).parseAssociatedNames((Item) job, names);
assertThat(names, Matchers.<GitHubRepositoryName>empty());
}

@Test
public void fetchSmokes() throws Exception {
SCMHeadObserver.Collector collector = SCMHeadObserver.collect();
Expand Down

0 comments on commit 0203fb2

Please sign in to comment.