tests: Allow to test project parameters
So far it wasn't possible to test the prameters of the project itself. While If7b749dae7631e8714a9416dfbd82d2443c0302c already made the job creation consistent this goes one step further and creates the root_xml using the project's root_xml method. Change-Id: Ieba4203d3d23ad68df5a1246e90ea8c03ddd54d4
This commit is contained in:
parent
b47fe61905
commit
d1846e7dfc
@ -25,6 +25,10 @@ import testtools
|
||||
import xml.etree.ElementTree as XML
|
||||
import yaml
|
||||
from jenkins_jobs.builder import XmlJob, YamlParser, ModuleRegistry
|
||||
from jenkins_jobs.modules import (project_flow,
|
||||
project_matrix,
|
||||
project_maven,
|
||||
project_multijob)
|
||||
|
||||
|
||||
def get_scenarios(fixtures_path):
|
||||
@ -75,21 +79,21 @@ class BaseTestCase(object):
|
||||
return
|
||||
|
||||
yaml_content, expected_xml = self.__read_content()
|
||||
|
||||
root_element = XML.Element('project')
|
||||
project = None
|
||||
if ('project-type' in yaml_content):
|
||||
if (yaml_content['project-type'] == "maven"):
|
||||
root_element = XML.Element('maven2-moduleset')
|
||||
if (yaml_content['project-type'] == "matrix"):
|
||||
root_element = XML.Element('matrix-project')
|
||||
if (yaml_content['project-type'] == "flow"):
|
||||
root_element = XML.Element('com.cloudbees.plugins.flow.'
|
||||
'BuildFlow')
|
||||
if (yaml_content['project-type'] == "multijob"):
|
||||
root_element = XML.Element('com.tikal.jenkins.plugins.'
|
||||
'multijob.MultiJobProject')
|
||||
project = project_maven.Maven(None)
|
||||
elif (yaml_content['project-type'] == "matrix"):
|
||||
project = project_matrix.Matrix(None)
|
||||
elif (yaml_content['project-type'] == "flow"):
|
||||
project = project_flow.Flow(None)
|
||||
elif (yaml_content['project-type'] == "multijob"):
|
||||
project = project_multijob.MultiJob(None)
|
||||
|
||||
xml_project = root_element
|
||||
if project:
|
||||
xml_project = project.root_xml(yaml_content)
|
||||
else:
|
||||
xml_project = XML.Element('project')
|
||||
parser = YamlParser()
|
||||
pub = self.klass(ModuleRegistry({}))
|
||||
|
||||
|
31
tests/general/fixtures/project-maven001.xml
Normal file
31
tests/general/fixtures/project-maven001.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<maven2-moduleset>
|
||||
<rootModule>
|
||||
<groupId>gabba.gabba</groupId>
|
||||
<artifactId>hey</artifactId>
|
||||
</rootModule>
|
||||
<goals>deploy</goals>
|
||||
<ignoreUpstremChanges>true</ignoreUpstremChanges>
|
||||
<rootPOM>pom.xml</rootPOM>
|
||||
<aggregatorStyleBuild>true</aggregatorStyleBuild>
|
||||
<incrementalBuild>false</incrementalBuild>
|
||||
<perModuleEmail>true</perModuleEmail>
|
||||
<archivingDisabled>false</archivingDisabled>
|
||||
<resolveDependencies>false</resolveDependencies>
|
||||
<processPlugins>false</processPlugins>
|
||||
<mavenValidationLevel>-1</mavenValidationLevel>
|
||||
<runHeadless>false</runHeadless>
|
||||
<settingConfigId/>
|
||||
<globalSettingConfigId/>
|
||||
<runPostStepsIfResult>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>red</color>
|
||||
</runPostStepsIfResult>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
</maven2-moduleset>
|
7
tests/general/fixtures/project-maven001.yaml
Normal file
7
tests/general/fixtures/project-maven001.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
project-type: maven
|
||||
maven:
|
||||
root-pom: pom.xml
|
||||
goals: deploy
|
||||
root-module:
|
||||
group-id: gabba.gabba
|
||||
artifact-id: hey
|
@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<matrix-project>
|
||||
<executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
|
||||
<runSequentially>false</runSequentially>
|
||||
</executionStrategy>
|
||||
<combinationFilter/>
|
||||
<axes/>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.cloudbees.plugins.flow.BuildFlow>
|
||||
<dsl/>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
|
Loading…
Reference in New Issue
Block a user