test(saltcheck): add test for cron envs (`absent` & `present`)

This commit is contained in:
Imran Iqbal 2019-11-03 08:12:03 +00:00
parent 59b66f0426
commit 82cd0a7f3a
No known key found for this signature in database
GPG Key ID: 6D8629439D2B7819
3 changed files with 29 additions and 1 deletions

View File

@ -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 %}

View File

@ -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: example@example.com
user: root
env3:
type: absent
name: LANG
value: en_GB.UTF-8
user: root