Skip to content

Commit

Permalink
useBuildDiscarder
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Oct 27, 2015
1 parent 7e08e34 commit 295ccd5
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import static org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProjectTest.scheduleAndFindBranchProject;
import org.junit.Ignore;

@Issue("JENKINS-30519")
public class JobPropertyStepTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
Expand All @@ -61,7 +62,6 @@ public class JobPropertyStepTest {

@Ignore("TODO fails with a JS TypeError, which goes away on new cores, maybe due to new HtmlUnit (1.627+); and needs https://github.com/jenkinsci/branch-api-plugin/pull/9")
@SuppressWarnings("rawtypes")
@Issue("JENKINS-30519")
@Test public void configRoundTripParameters() throws Exception {
StepConfigTester tester = new StepConfigTester(r);
assertEquals(Collections.emptyList(), tester.configRoundTrip(new JobPropertyStep(Collections.<JobProperty>emptyList())).getProperties());
Expand All @@ -79,7 +79,6 @@ public class JobPropertyStepTest {

@Ignore("TODO as above")
@SuppressWarnings("rawtypes")
@Issue("JENKINS-30519")
@Test public void configRoundTripBuildDiscarder() throws Exception {
StepConfigTester tester = new StepConfigTester(r);
assertEquals(Collections.emptyList(), tester.configRoundTrip(new JobPropertyStep(Collections.<JobProperty>emptyList())).getProperties());
Expand Down Expand Up @@ -120,4 +119,25 @@ public class JobPropertyStepTest {
r.assertLogContains("received special value", b2);
}

@SuppressWarnings("deprecation") // RunList.size
@Test public void useBuildDiscarder() throws Exception {
sampleRepo.init();
sampleRepo.write("Jenkinsfile", "properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '1']]])");
sampleRepo.git("add", "Jenkinsfile");
sampleRepo.git("commit", "--all", "--message=flow");
WorkflowMultiBranchProject mp = r.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
WorkflowJob p = scheduleAndFindBranchProject(mp, "master");
assertEquals(1, mp.getItems().size());
r.waitUntilNoActivity(); // #1 built automatically
assertEquals(1, p.getBuilds().size());
r.assertBuildStatusSuccess(p.scheduleBuild2(0)); // #2
assertEquals(1, p.getBuilds().size());
r.assertBuildStatusSuccess(p.scheduleBuild2(0)); // #3
assertEquals(1, p.getBuilds().size());
WorkflowRun b3 = p.getLastBuild();
assertEquals(3, b3.getNumber());
assertNull(b3.getPreviousBuild());
}

}

0 comments on commit 295ccd5

Please sign in to comment.