From 9ca0e3c2a6202e3e8151edc13c5d22857aa12612 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 20 Oct 2014 09:21:50 +0800 Subject: [PATCH] Add tests for properties inject Replace hard-coded inject example with a literal include. Extend the example to show how to pass two environment variables. Add test fixtures for the keep-system-variables and keep-build-variables parameters. Change-Id: Ie3b5af2c38f8dde5ff739b9f6b213c1e94387aca --- jenkins_jobs/modules/properties.py | 10 +++++----- tests/properties/fixtures/inject001.xml | 16 ++++++++++++++++ tests/properties/fixtures/inject001.yaml | 5 +++++ tests/properties/fixtures/inject002.xml | 13 +++++++++++++ tests/properties/fixtures/inject002.yaml | 3 +++ tests/properties/fixtures/inject003.xml | 13 +++++++++++++ tests/properties/fixtures/inject003.yaml | 4 ++++ 7 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 tests/properties/fixtures/inject001.xml create mode 100644 tests/properties/fixtures/inject001.yaml create mode 100644 tests/properties/fixtures/inject002.xml create mode 100644 tests/properties/fixtures/inject002.yaml create mode 100644 tests/properties/fixtures/inject003.xml create mode 100644 tests/properties/fixtures/inject003.yaml diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index ee465167b..29554e320 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -213,7 +213,7 @@ def throttle(parser, xml_parent, data): def inject(parser, xml_parent, data): """yaml: inject - Allows you to inject evironment variables into the build. + Allows you to inject environment variables into the build. Requires the Jenkins `Env Inject Plugin. `_ @@ -227,11 +227,11 @@ def inject(parser, xml_parent, data): :arg bool keep-system-variables: keep system variables (default true) :arg bool keep-build-variables: keep build variable (default true) - Example:: + Example: + + .. literalinclude:: /../../tests/properties/fixtures/inject001.yaml + :language: yaml - properties: - - inject: - properties-content: FOO=bar """ inject = XML.SubElement(xml_parent, 'EnvInjectJobProperty') diff --git a/tests/properties/fixtures/inject001.xml b/tests/properties/fixtures/inject001.xml new file mode 100644 index 000000000..4a8b3f757 --- /dev/null +++ b/tests/properties/fixtures/inject001.xml @@ -0,0 +1,16 @@ + + + + + + FOO=bar + BAZ=foobar + + false + + true + true + true + + + diff --git a/tests/properties/fixtures/inject001.yaml b/tests/properties/fixtures/inject001.yaml new file mode 100644 index 000000000..5da27be9a --- /dev/null +++ b/tests/properties/fixtures/inject001.yaml @@ -0,0 +1,5 @@ +properties: + - inject: + properties-content: | + FOO=bar + BAZ=foobar diff --git a/tests/properties/fixtures/inject002.xml b/tests/properties/fixtures/inject002.xml new file mode 100644 index 000000000..9a5e12f94 --- /dev/null +++ b/tests/properties/fixtures/inject002.xml @@ -0,0 +1,13 @@ + + + + + + false + + true + true + true + + + diff --git a/tests/properties/fixtures/inject002.yaml b/tests/properties/fixtures/inject002.yaml new file mode 100644 index 000000000..8c149b73b --- /dev/null +++ b/tests/properties/fixtures/inject002.yaml @@ -0,0 +1,3 @@ +properties: + - inject: + enabled: true diff --git a/tests/properties/fixtures/inject003.xml b/tests/properties/fixtures/inject003.xml new file mode 100644 index 000000000..4572543d3 --- /dev/null +++ b/tests/properties/fixtures/inject003.xml @@ -0,0 +1,13 @@ + + + + + + false + + true + false + false + + + diff --git a/tests/properties/fixtures/inject003.yaml b/tests/properties/fixtures/inject003.yaml new file mode 100644 index 000000000..eb96d0a2c --- /dev/null +++ b/tests/properties/fixtures/inject003.yaml @@ -0,0 +1,4 @@ +properties: + - inject: + keep-build-variables: false + keep-system-variables: false