@@ -9,6 +9,7 @@ import hudson.model.Cause
99import hudson.model.Failure
1010import hudson.model.FreeStyleBuild
1111import hudson.model.FreeStyleProject
12+ import hudson.model.Job
1213import hudson.model.ListView
1314import hudson.model.Run
1415import hudson.model.View
@@ -47,12 +48,24 @@ class JenkinsJobManagementSpec extends Specification {
4748 @Rule
4849 JenkinsRule jenkinsRule = new JenkinsRule ()
4950
50- ByteArrayOutputStream buffer = new ByteArrayOutputStream ()
51- Run build = Mock (Run )
52- JenkinsJobManagement jobManagement = new JenkinsJobManagement (
53- new PrintStream (buffer), [:], build, new FilePath (new File (' .' )), LookupStrategy . JENKINS_ROOT
54- )
55- JenkinsJobManagement testJobManagement = new JenkinsJobManagement (new PrintStream (buffer), [:], new File (' .' ))
51+ ByteArrayOutputStream buffer
52+ Job seedJob
53+ Run build
54+ JenkinsJobManagement jobManagement
55+ JenkinsJobManagement testJobManagement
56+
57+ def setup () {
58+ seedJob = Mock (Job )
59+ build = Mock (Run )
60+
61+ build. parent >> seedJob
62+
63+ buffer = new ByteArrayOutputStream ()
64+ jobManagement = new JenkinsJobManagement (
65+ new PrintStream (buffer), [:], build, new FilePath (new File (' .' )), LookupStrategy . JENKINS_ROOT
66+ )
67+ testJobManagement = new JenkinsJobManagement (new PrintStream (buffer), [:], new File (' .' ))
68+ }
5669
5770 @WithoutJenkins
5871 def ' createOrUpdateView without name' () {
@@ -837,6 +850,23 @@ class JenkinsJobManagementSpec extends Specification {
837850 project.builds.lastBuild.causes[0].shortDescription == ' Started by a Job DSL script'
838851 }
839852
853+ def ' parameters include SEED_JOB ' () {
854+ when:
855+ Map<String, Object> parameters = jobManagement.parameters
856+
857+ then:
858+ parameters.containsKey(' SEED_JOB ' )
859+ parameters.SEED_JOB == seedJob
860+ }
861+
862+ def ' parameters do not include SEED_JOB for testing' () {
863+ when:
864+ Map<String, Object> parameters = testJobManagement.parameters
865+
866+ then:
867+ !parameters.containsKey(' SEED_JOB ' )
868+ }
869+
840870 private static boolean isXmlIdentical(String expected, Node actual) throws Exception {
841871 XMLUnit.ignoreWhitespace = true
842872 XMLUnit.compareXML(loadResource(expected), nodeToString(actual)).identical()
0 commit comments