0
0
mirror of https://github.com/saltstack-formulas/cron-formula.git synced 2024-12-18 17:00:41 +01:00
cron-formula/cron/saltcheck-tests/config/file.tst

48 lines
1.4 KiB
Scilab

# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set cron = salt['pillar.get']('cron', {}) %}
{%- for task, task_options in cron.get('tasks', {}).items() %}
{%- set cron_type = task_options.type|d('present') %}
validate_cron.{{ task }}_{{ cron_type }}:
module_and_function: cron.get_entry
args:
- {{ task_options.user|d('root') }}
- {{ task }}
{%- if cron_type == 'absent' %}
assertion: assertFalse
{%- else %}
assertion: assertEqual
assertion_section: identifier
expected-return: {{ task }}
{%- endif %}
{%- if cron_type == 'present' %}
validate_cron.{{ task }}_commented:
module_and_function: cron.get_entry
args:
- {{ task_options.user|d('root') }}
- {{ task }}
assertion: {{ 'assertTrue' if task_options.commented|d(False) else 'assertFalse' }}
assertion_section: commented
{#- Note: `special` is `spec` in the module #}
{%- for section in ['minute', 'hour', 'daymonth', 'month', 'dayweek', 'comment', 'spec'] %}
{%- if section in task_options %}
{%- set expected = task_options[section] %}
validate_cron.{{ task }}_{{ section }}:
module_and_function: cron.get_entry
args:
- {{ task_options.user|d('root') }}
- {{ task }}
assertion: {{ 'assertLessEqual' if expected == 'random' else 'assertEqual' }}
assertion_section: {{ section }}
expected-return: '{{ 0 if expected == 'random' else expected }}'
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}