Skip to content

Commit

Permalink
Merge pull request #13 from myii/test/add-saltcheck-test-for-envs
Browse files Browse the repository at this point in the history
test(saltcheck): add test for cron envs (`absent` & `present`)
  • Loading branch information
aboe76 authored Nov 4, 2019
2 parents c47e43c + 82cd0a7 commit 4233af9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cron/config/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cron.{{ task }}:
{%- endfor %}
{%- for env, env_options in cron.get('env', {}). items() %}
{%- set env_type = env_options.type|d('present') %}
{%- set env_type = env_options.type|d('present') %}
cron.{{ env }}:
cron.env_{{ env_type }}:
Expand Down
12 changes: 12 additions & 0 deletions cron/saltcheck-tests/config/file.tst
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,15 @@ validate_cron.{{ task }}_{{ section }}:
{%- endif %}
{%- endfor %}
{%- for env, env_options in cron.get('env', {}). items() %}
{%- set env_type = env_options.type|d('present') %}

validate_cron.{{ env }}_{{ env_type }}:
module_and_function: cron.raw_cron
args:
- {{ env_options.user|d('root') }}
assertion: {{ 'assertNotIn' if env_type == 'absent' else 'assertIn' }}
expected-return: '{{ env_options.name }}={{ env_options.value }}'

{%- endfor %}
16 changes: 16 additions & 0 deletions test/salt/pillar/cron.sls
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,19 @@ cron:
minute: random
hour: 1
commented: true
env:
env1:
type: present
name: PATH
value: /usr/local/bin:/usr/bin:/bin:/usr/games
user: root
env2:
type: present
name: MAILTO
value: [email protected]
user: root
env3:
type: absent
name: LANG
value: en_GB.UTF-8
user: root

0 comments on commit 4233af9

Please sign in to comment.