Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXED JENKINS-11609] improve the robustness of the resolve()
- Loading branch information
Showing
4 changed files
with
58 additions
and
3 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
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
42 changes: 42 additions & 0 deletions
42
src/test/java/hudson/plugins/promoted_builds/PromotionTargetActionTest.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,42 @@ | ||
package hudson.plugins.promoted_builds; | ||
|
||
import hudson.model.FreeStyleBuild; | ||
import hudson.model.FreeStyleProject; | ||
import hudson.model.ParameterValue; | ||
import hudson.plugins.promoted_builds.conditions.ManualCondition; | ||
import hudson.plugins.promoted_builds.conditions.ManualCondition.ManualApproval; | ||
import org.jvnet.hudson.test.HudsonTestCase; | ||
|
||
import java.util.Collections; | ||
|
||
/** | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public class PromotionTargetActionTest extends HudsonTestCase { | ||
/** | ||
* When a project is created, built, and renamed, then the old build is created, | ||
* that results in NPE. | ||
*/ | ||
public void test1() throws Exception { | ||
FreeStyleProject up = createFreeStyleProject("up"); | ||
up.setCustomWorkspace(createTmpDir().getPath()); | ||
|
||
// promote if the downstream passes | ||
JobPropertyImpl promotion = new JobPropertyImpl(up); | ||
up.addProperty(promotion); | ||
PromotionProcess proc = promotion.addProcess("promo"); | ||
proc.conditions.add(new ManualCondition()); | ||
|
||
FreeStyleBuild b = assertBuildStatusSuccess(up.scheduleBuild2(0)); | ||
|
||
b.addAction(new ManualApproval(proc.getName(), Collections.<ParameterValue>emptyList())); | ||
b.save(); | ||
|
||
// check for promotion | ||
Promotion p = assertBuildStatusSuccess(proc.considerPromotion2(b)); | ||
|
||
up.renameTo("up2"); | ||
|
||
assertSame(b,p.getTarget()); | ||
} | ||
} |