ワンクリックで
run-tests
// Runs and writes tests (sanity, unit, integration) for this Ansible collection using ansible-test. Use when asked to run, check, or write tests for a module or utility. Do not use for PR reviews or questions unrelated to testing.
// Runs and writes tests (sanity, unit, integration) for this Ansible collection using ansible-test. Use when asked to run, check, or write tests for a module or utility. Do not use for PR reviews or questions unrelated to testing.
| name | run-tests |
| description | Runs and writes tests (sanity, unit, integration) for this Ansible collection using ansible-test. Use when asked to run, check, or write tests for a module or utility. Do not use for PR reviews or questions unrelated to testing. |
Run and write tests for this Ansible collection. Covers sanity, unit, and integration tests using ansible-test.
TRIGGER when:
DO NOT TRIGGER when:
.agents/skills/pr-review/SKILL.md instead)All tests run inside Docker/Podman via ansible-test --docker. No local package installation is needed. The collection must be installed at ansible_collections/community/libvirt/ (relative to a directory on ANSIBLE_COLLECTIONS_PATHS) for imports to resolve correctly.
Checks style, documentation, and imports for a changed file:
ansible-test sanity plugins/modules/virt.py --docker -vvv
Runs unit tests for changed files:
ansible-test units tests/unit/plugins/modules/test_virt.py --docker -vvv
Unit tests live under tests/unit/plugins/ and use the PyTest framework. Every new function or class method MUST have a corresponding unit test.
Runs integration tests against a target environment (started by Docker):
ansible-test integration virt --docker default -vvv
ansible-test integration virt_net --docker default -vvv
Integration tests live under tests/integration/targets/<module_name>/.
| Change type | Sanity | Unit | Integration |
|---|---|---|---|
| New module | yes | yes | yes |
| New parameter | yes | if logic changed | yes |
| Bug fix | yes | yes | yes |
| Refactoring | yes | yes | no |
| Documentation only | yes | no | no |
Every integration test target must follow this sequence:
register: resultresult using ansible.builtin.assertregister: result → ansible.builtin.assertcheck_mode: true as well- name: Create network in check mode
check_mode: true
community.libvirt.virt_net:
name: testnet
command: define
xml: '{{ lookup("template", "testnet.xml.j2") }}'
register: result
- name: Assert changed
ansible.builtin.assert:
that:
- result is changed
- name: Create network in real mode
community.libvirt.virt_net:
name: testnet
command: define
xml: '{{ lookup("template", "testnet.xml.j2") }}'
register: result
- name: Assert changed
ansible.builtin.assert:
that:
- result is changed
Tests must also cover:
result is not changed.state: absent: where applicable, remove the resource and assert it is gone.This skill should be used when the user asks to 'commit', 'create a commit', or 'git commit'. It creates conventional commits with FQCN scopes for Ansible collection content (roles, modules, plugins).
Reviews pull requests and code changes in this Ansible collection against project standards and the Ansible Collection Review Checklist. Use when asked to review a PR, patch, diff, or set of code changes. Do not use for GitHub Issues or general Q&A.