-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from arthurschreiber/arthur/extend-workflow-s…
…upport Show the "GitHub" link for Workflow projects
- Loading branch information
Showing
3 changed files
with
82 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/test/java/com/coravy/hudson/plugins/github/GithubLinkActionFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.coravy.hudson.plugins.github; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.instanceOf; | ||
import static org.hamcrest.Matchers.empty; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
|
||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import com.coravy.hudson.plugins.github.GithubLinkAction.GithubLinkActionFactory; | ||
|
||
import hudson.model.Action; | ||
|
||
public class GithubLinkActionFactoryTest { | ||
@Rule | ||
public final JenkinsRule rule = new JenkinsRule(); | ||
|
||
private final GithubLinkActionFactory factory = new GithubLinkActionFactory(); | ||
|
||
private static final String PROJECT_URL = "https://github.com/jenkinsci/github-plugin/"; | ||
|
||
private WorkflowJob createExampleJob() throws IOException { | ||
return rule.getInstance().createProject(WorkflowJob.class, "example"); | ||
} | ||
|
||
private GithubProjectProperty createExampleProperty() { | ||
return new GithubProjectProperty(PROJECT_URL); | ||
} | ||
|
||
@Test | ||
public void shouldCreateGithubLinkActionForJobWithGithubProjectProperty() throws IOException { | ||
final WorkflowJob job = createExampleJob(); | ||
final GithubProjectProperty property = createExampleProperty(); | ||
job.addProperty(property); | ||
|
||
final Collection<? extends Action> actions = factory.createFor(job); | ||
assertThat("factored actions list", actions.size(), is(1)); | ||
|
||
final Action action = actions.iterator().next(); | ||
assertThat("instance check", action, is(instanceOf(GithubLinkAction.class))); | ||
assertThat("url of action", action.getUrlName(), is(property.getProjectUrlStr())); | ||
} | ||
|
||
@Test | ||
public void shouldNotCreateGithubLinkActionForJobWithoutGithubProjectProperty() throws IOException { | ||
final WorkflowJob job = createExampleJob(); | ||
|
||
final Collection<? extends Action> actions = factory.createFor(job); | ||
assertThat("factored actions list", actions, is(empty())); | ||
} | ||
} |