Skip to content
Permalink
Browse files

[JENKINS-48035] negative tests

  • Loading branch information
rsandell committed Dec 12, 2017
1 parent 361e6d1 commit 0203fb201fc886ac826c96386f88b3d7775ab8f1
Showing with 26 additions and 0 deletions.
  1. +26 −0 src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java
@@ -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;
@@ -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();

0 comments on commit 0203fb2

Please sign in to comment.
You can’t perform that action at this time.