mirror of
https://github.com/saltstack-formulas/cron-formula.git
synced 2025-04-20 15:32:05 +02:00
test(saltcheck): add first tests
This commit is contained in:
parent
86385672e9
commit
9847aff516
103
cron/saltcheck-tests/config.tst
Normal file
103
cron/saltcheck-tests/config.tst
Normal file
@ -0,0 +1,103 @@
|
||||
{%- from "cron/map.jinja" import cron_settings with context %}
|
||||
|
||||
{%- if 'tasks' in cron_settings %}
|
||||
{%- for task,task_options in cron_settings.tasks.items() %}
|
||||
|
||||
{%- if task_options.type == 'present' %}
|
||||
validate_cron.{{ task }}_exists:
|
||||
module_and_function: cron.get_entry
|
||||
args:
|
||||
- {{ task_options.user|default('root') }}
|
||||
- {{ task }}
|
||||
assertion: assertEqual
|
||||
assertion_section: identifier
|
||||
expected-return: {{ task }}
|
||||
|
||||
{%- if 'minute' in task_options %}
|
||||
validate_cron.{{ task }}_minute:
|
||||
module_and_function: cron.get_entry
|
||||
args:
|
||||
- {{ task_options.user|default('root') }}
|
||||
- {{ task }}
|
||||
assertion: assertEqual
|
||||
assertion_section: minute
|
||||
expected-return: {{ task_options.minute }}
|
||||
{%- endif %}
|
||||
|
||||
{%- if 'hour' in task_options %}
|
||||
validate_cron.{{ task }}_hour:
|
||||
module_and_function: cron.get_entry
|
||||
args:
|
||||
- {{ task_options.user|default('root') }}
|
||||
- {{ task }}
|
||||
assertion_section: hour
|
||||
assertion: assertEqual
|
||||
expected-return: {{ task_options.hour }}
|
||||
{%- endif %}
|
||||
|
||||
{%- if 'daymonth' in task_options %}
|
||||
validate_cron.{{ task }}_daymonth:
|
||||
module_and_function: cron.get_entry
|
||||
args:
|
||||
- {{ task_options.user|default('root') }}
|
||||
- {{ task }}
|
||||
assertion_section: daymonth
|
||||
assertion: assertEqual
|
||||
expected-return: {{ task_options.daymonth }}
|
||||
{%- endif %}
|
||||
|
||||
{%- if 'month' in task_options %}
|
||||
validate_cron.{{ task }}_month:
|
||||
module_and_function: cron.get_entry
|
||||
args:
|
||||
- {{ task_options.user|default('root') }}
|
||||
- {{ task }}
|
||||
assertion_section: month
|
||||
assertion: assertEqual
|
||||
expected-return: {{ task_options.month }}
|
||||
{%- endif %}
|
||||
|
||||
{%- if 'dayweek' in task_options %}
|
||||
validate_cron.{{ task }}_dayweek:
|
||||
module_and_function: cron.get_entry
|
||||
args:
|
||||
- {{ task_options.user|default('root') }}
|
||||
- {{ task }}
|
||||
assertion_section: dayweek
|
||||
assertion: assertEqual
|
||||
expected-return: {{ task_options.dayweek }}
|
||||
{%- endif %}
|
||||
|
||||
{%- if 'comment' in task_options %}
|
||||
validate_cron.{{ task }}_comment:
|
||||
module_and_function: cron.get_entry
|
||||
args:
|
||||
- {{ task_options.user|default('root') }}
|
||||
- {{ task }}
|
||||
assertion_section: comment
|
||||
assertion: assertEqual
|
||||
expected-return: {{ task_options.comment }}
|
||||
{%- endif %}
|
||||
|
||||
{%- if 'commented' in task_options and task_options.commented %}
|
||||
validate_cron.{{ task }}_commented:
|
||||
module_and_function: cron.get_entry
|
||||
args:
|
||||
- {{ task_options.user|default('root') }}
|
||||
- {{ task }}
|
||||
assertion_section: commented
|
||||
assertion: assertTrue
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
|
||||
{%- if task_options.type == 'absent' %}
|
||||
validate_cron.{{ task }}_absent:
|
||||
module_and_function: cron.get_entry
|
||||
args:
|
||||
- {{ task_options.user|default('root') }}
|
||||
- {{ task }}
|
||||
assertion: assertFalse
|
||||
{%- endif %}
|
||||
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
8
cron/saltcheck-tests/install.tst
Normal file
8
cron/saltcheck-tests/install.tst
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
m "cron/map.jinja" import cron_settings with context %}
|
||||
|
||||
verify_cron.install:
|
||||
module_and_function: pkg.version
|
||||
args:
|
||||
- {{ cron_settings.pkg }}
|
||||
assertion: assertNotEmpty
|
15
cron/saltcheck-tests/service.tst
Normal file
15
cron/saltcheck-tests/service.tst
Normal file
@ -0,0 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
{%- from "cron/map.jinja" import cron_settings with context %}
|
||||
|
||||
cron.service:
|
||||
{%- if 'enabled' not in cron_settings or ( 'enabled' in cron_settings and cron_settings.enabled ) %}
|
||||
service.running:
|
||||
- name: {{ cron_settings.service }}
|
||||
- enable: True
|
||||
{%- else %}
|
||||
service.dead:
|
||||
- name: {{ cron_settings.service }}
|
||||
- enable: False
|
||||
{%- endif %}
|
Loading…
x
Reference in New Issue
Block a user