mirror of
https://github.com/saltstack-formulas/cron-formula.git
synced 2026-10-08 12:03:06 +02:00
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:
3 files changed
No files matched your search
@@ -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 %}
|
||||
Reference in new issue
Block a user