refactor(saltcheck): relocate .tst files according to 1:1 .sls files

* https://github.com/saltstack-formulas/cron-formula/pull/4#issuecomment-544140377
This commit is contained in:
Imran Iqbal committed 2019-10-23 19:02:17 +01:00
1 parent 7e9e619a37
commit ee652363ff
3 files changed

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
# -*- 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 %}