Runs on noble and resolute without the real Pi-hole: the clone target is a local git repository whose installer is a stub that logs its arguments and creates the database file. Covers a check run before the converge and after idempotence, the merge, the rendered pihole.toml (upstreams, interface, hashed password, owner and mode), the system user, the installer sequence (install once, then reconfigure from the handler) and a negative test for every validation: no Ubuntu facts, a missing pihole_web_password, an unset interface, empty upstreams, a non-string and a placeholder password. No pihole-FTL service runs, so the loaded configuration is not verified. Assisted-by: Claude Code:claude-opus-5-5
25 lines
1.2 KiB
YAML
25 lines
1.2 KiB
YAML
---
|
|
# One failing run: runs the role with the inputs of the case and asserts that the expected
|
|
# message, not something else, stopped it. Input: pihole_test_case (name, overrides, expect);
|
|
# the web password is always set here, so the validation under test is the first to fail.
|
|
- name: "Run the role, case {{ pihole_test_case.name }}"
|
|
block:
|
|
- name: "Include the role, case {{ pihole_test_case.name }}"
|
|
ansible.builtin.include_role:
|
|
name: mortis.kamino.pihole
|
|
vars:
|
|
pihole_web_password: not-used
|
|
pihole_overrides: "{{ pihole_test_case.overrides }}"
|
|
|
|
# Only reached when the include returned. The message must not contain the expected
|
|
# text, so the rescue below cannot mistake it for the failure under test.
|
|
- name: "Fail because the include returned, case {{ pihole_test_case.name }}"
|
|
ansible.builtin.fail:
|
|
msg: The role accepted the input
|
|
rescue:
|
|
- name: "The expected failure stopped the run, case {{ pihole_test_case.name }}"
|
|
ansible.builtin.assert:
|
|
that: pihole_test_case.expect in (ansible_failed_result.msg | default(''))
|
|
fail_msg: "Expected '{{ pihole_test_case.expect }}', got: {{ ansible_failed_result.msg | default('') }}"
|
|
quiet: true
|