Give each new input its own assert message so every refused-input case matches only its own input, and cover a negative count and a bad disk check schedule. Fire the pressure prune only above the threshold, as the inputs describe it. Name the disk check script apart from the pressure service, prefix the new registers as internal, and keep the new comments short. Refs #319 Assisted-by: Claude Code
33 lines
2.5 KiB
YAML
33 lines
2.5 KiB
YAML
---
|
|
# One refused input: runs the main entry point with that input and asserts that the expected
|
|
# assert, not something else, stopped it. Input: gitea_runner_test_refused (name, vars, expect).
|
|
# Task vars cannot come from a template as a whole, so each input under test is passed with
|
|
# its usual value as the default.
|
|
- name: "Run the role, case {{ gitea_runner_test_refused.name }}"
|
|
block:
|
|
- name: "Include the role, case {{ gitea_runner_test_refused.name }}"
|
|
ansible.builtin.include_role:
|
|
name: mortis.kamino.gitea_runner
|
|
vars:
|
|
gitea_runner_version: "{{ gitea_runner_test_refused.vars.gitea_runner_version | default('6.0.1') }}"
|
|
gitea_runner_registration_scope: "{{ gitea_runner_test_refused.vars.gitea_runner_registration_scope | default('') }}"
|
|
gitea_runner_docker_prune_schedule: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_schedule | default('Sun *-*-* 04:30:00') }}"
|
|
gitea_runner_docker_prune_image_age: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_image_age | default('168h') }}"
|
|
gitea_runner_docker_prune_keep_per_repository: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_keep_per_repository | default(2) }}"
|
|
gitea_runner_docker_prune_disk_threshold_percent: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_disk_threshold_percent | default(90) }}"
|
|
gitea_runner_docker_prune_disk_check_schedule: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_disk_check_schedule | default('hourly') }}"
|
|
gitea_runner_docker_prune_builder_keep_storage: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_builder_keep_storage | default('10GB') }}"
|
|
gitea_runner_molecule_enabled: "{{ gitea_runner_test_refused.vars.gitea_runner_molecule_enabled | default(false) }}"
|
|
|
|
# Only reached when the include returned. The message must not contain the expected
|
|
# text, so the rescue below cannot mistake it for the assert.
|
|
- name: "Fail because the include returned, case {{ gitea_runner_test_refused.name }}"
|
|
ansible.builtin.fail:
|
|
msg: The role accepted the input
|
|
rescue:
|
|
- name: "The expected assert fired, case {{ gitea_runner_test_refused.name }}"
|
|
ansible.builtin.assert:
|
|
that: gitea_runner_test_refused.expect in ansible_failed_result.msg | default('')
|
|
fail_msg: "Expected '{{ gitea_runner_test_refused.expect }}', got: {{ ansible_failed_result.msg | default('') }}"
|
|
quiet: true
|