-
Notifications
You must be signed in to change notification settings - Fork 610
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 #741 from mayt/fix-ghprbcancelbuildsorupdate
GhprbCancelBuildsOnUpdate loops through queue items
- Loading branch information
Showing
2 changed files
with
68 additions
and
22 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
45 changes: 45 additions & 0 deletions
45
...test/java/org/jenkinsci/plugins/ghprb/extensions/build/GhprbCancelBuildsOnUpdateTest.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,45 @@ | ||
package org.jenkinsci.plugins.ghprb.extensions.build; | ||
|
||
import hudson.model.FreeStyleProject; | ||
import org.jenkinsci.plugins.ghprb.GhprbITBaseTestCase; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.mockito.BDDMockito.given; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class GhprbCancelBuildsOnUpdateTest extends GhprbITBaseTestCase { | ||
|
||
@Rule | ||
public JenkinsRule jenkinsRule = new JenkinsRule(); | ||
|
||
private FreeStyleProject project; | ||
|
||
private GhprbCancelBuildsOnUpdate gcbou; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
project = jenkinsRule.getInstance().createProject(FreeStyleProject.class, "FSPRJ"); | ||
|
||
Map<String, Object> config = new HashMap<>(1); | ||
|
||
super.beforeTest(config, null, project); | ||
|
||
given(ghprbPullRequest.getPullRequestAuthor()).willReturn(ghUser); | ||
|
||
gcbou = new GhprbCancelBuildsOnUpdate(false); | ||
} | ||
|
||
@Test | ||
public void testCancelCurrentBuilds() { | ||
builds.build(ghprbPullRequest, ghUser, ""); | ||
gcbou.cancelCurrentBuilds(project, 1); | ||
} | ||
} |