diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61eb901..7c39571 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -198,6 +198,9 @@ commitlint: | tee -a ${PKGS_VERSIONS_FILE}' - 'docker exec "${TESTINFRA_CONTAINER}" ${CMD_SALT_CALL_PIP_LIST} | tee -a ${PKGS_VERSIONS_FILE}' + # Prepare the `test_jinja` state files + - 'docker exec "${TESTINFRA_CONTAINER}" mkdir -p /srv/salt/' + - 'docker cp test/test_jinja/ ${TESTINFRA_CONTAINER}:/srv/salt/test_jinja/' # Run the integration tests # Not using `${SVB}` instead of `${SV}` here since the test file itself handles # the any version number issues (e.g. the extra `.0` in the version number). diff --git a/.yamllint b/.yamllint index 8565bf9..ea47afa 100644 --- a/.yamllint +++ b/.yamllint @@ -5,13 +5,13 @@ extends: 'default' # Files to ignore completely -# 1. All YAML files under directory `node_modules/`, introduced during the Travis run +# 1. All YAML files under directory `node_modules/`, introduced during the CI run # 2. Any SLS files under directory `test/`, which are actually state files # 3. Any YAML files under directory `.kitchen/`, introduced during local testing ignore: | node_modules/ + test/test_jinja/ .kitchen/ - .travis.yml yaml-files: # Default settings diff --git a/test/integration/test_jinja.py b/test/integration/test_jinja.py new file mode 100644 index 0000000..e2a0237 --- /dev/null +++ b/test/integration/test_jinja.py @@ -0,0 +1,18 @@ +def test_jinja_grains(host): + cmd = host.run("salt-call --local state.sls test_jinja.grains") + assert cmd.rc == 0 + + +def test_jinja_opts(host): + cmd = host.run("salt-call --local state.sls test_jinja.opts") + assert cmd.rc == 0 + + +def test_jinja_pillar(host): + cmd = host.run("salt-call --local state.sls test_jinja.pillar") + assert cmd.rc == 0 + + +def test_jinja_salt(host): + cmd = host.run("salt-call --local state.sls test_jinja.salt") + assert cmd.rc == 0 diff --git a/test/test_jinja/grains.jinja b/test/test_jinja/grains.jinja new file mode 100644 index 0000000..57b0696 --- /dev/null +++ b/test/test_jinja/grains.jinja @@ -0,0 +1 @@ +{%- import_yaml "./grains.yaml" as grains %} diff --git a/test/test_jinja/grains.sls b/test/test_jinja/grains.sls new file mode 100644 index 0000000..6fc8db3 --- /dev/null +++ b/test/test_jinja/grains.sls @@ -0,0 +1,5 @@ +{%- from "test_jinja/grains.jinja" import grains with context %} + +test_jinja/grains/cmd.run: + cmd.run: + - name: pwd diff --git a/test/test_jinja/grains.yaml b/test/test_jinja/grains.yaml new file mode 100644 index 0000000..26e406b --- /dev/null +++ b/test/test_jinja/grains.yaml @@ -0,0 +1 @@ +{%- set grains = grains.get('os', '') %} diff --git a/test/test_jinja/opts.jinja b/test/test_jinja/opts.jinja new file mode 100644 index 0000000..f71698a --- /dev/null +++ b/test/test_jinja/opts.jinja @@ -0,0 +1 @@ +{%- import_yaml "./opts.yaml" as opts %} diff --git a/test/test_jinja/opts.sls b/test/test_jinja/opts.sls new file mode 100644 index 0000000..599bcd1 --- /dev/null +++ b/test/test_jinja/opts.sls @@ -0,0 +1,5 @@ +{%- from "test_jinja/opts.jinja" import opts with context %} + +test_jinja/opts/cmd.run: + cmd.run: + - name: pwd diff --git a/test/test_jinja/opts.yaml b/test/test_jinja/opts.yaml new file mode 100644 index 0000000..4286773 --- /dev/null +++ b/test/test_jinja/opts.yaml @@ -0,0 +1 @@ +{%- set opts = opts.get('__cli', '') %} diff --git a/test/test_jinja/pillar.jinja b/test/test_jinja/pillar.jinja new file mode 100644 index 0000000..9c24fdc --- /dev/null +++ b/test/test_jinja/pillar.jinja @@ -0,0 +1 @@ +{%- import_yaml "./pillar.yaml" as pillar %} diff --git a/test/test_jinja/pillar.sls b/test/test_jinja/pillar.sls new file mode 100644 index 0000000..883c7a8 --- /dev/null +++ b/test/test_jinja/pillar.sls @@ -0,0 +1,5 @@ +{%- from "test_jinja/pillar.jinja" import pillar with context %} + +test_jinja/pillar/cmd.run: + cmd.run: + - name: pwd diff --git a/test/test_jinja/pillar.yaml b/test/test_jinja/pillar.yaml new file mode 100644 index 0000000..0c160af --- /dev/null +++ b/test/test_jinja/pillar.yaml @@ -0,0 +1 @@ +{%- set pillar = pillar.get('pillar', '') %} diff --git a/test/test_jinja/salt.jinja b/test/test_jinja/salt.jinja new file mode 100644 index 0000000..13616a9 --- /dev/null +++ b/test/test_jinja/salt.jinja @@ -0,0 +1 @@ +{%- import_yaml "./salt.yaml" as salt %} diff --git a/test/test_jinja/salt.sls b/test/test_jinja/salt.sls new file mode 100644 index 0000000..0bb1142 --- /dev/null +++ b/test/test_jinja/salt.sls @@ -0,0 +1,5 @@ +{%- from "test_jinja/salt.jinja" import salt with context %} + +test_jinja/salt/cmd.run: + cmd.run: + - name: pwd diff --git a/test/test_jinja/salt.yaml b/test/test_jinja/salt.yaml new file mode 100644 index 0000000..1243872 --- /dev/null +++ b/test/test_jinja/salt.yaml @@ -0,0 +1 @@ +{%- set salt = salt['pillar.get']('salt', '') %}