mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
7b73a83b91
* Add more default license and copyright notices.
* Fix tests.
* Fix typos.
* Fix task type.
* Add URL to changelog fragment.
* Improve headers for setup_wildfly_server.
(cherry picked from commit 9327b12c4d
)
Co-authored-by: Felix Fontein <felix@fontein.de>
1.5 KiB
1.5 KiB
interfaces_file unit tests
Tests structure
input
directory contains interfaces configuration filestest_interfaces_file.py
runs each hardcoded test against all configurations ininput
directory and compares results with golden outputs ingolden_output
Running unit tests with docker
- Clone project to
ansible_collections/community/general
- Change directory to the project one
cd ansible_collections/community/general
- Run
ansible-test units --docker -v --python 3.6 tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py
Adding tests
- New configurations should added to
input
directory - New test cases should be defined in
test_interfaces_file.py
. Same for new test functions if needed - On first test run for a new combination of a test case and an interface configuration new set of golden files will be generated. In case of docker-based test approach that's going to fail due to RO mount option. The workaround is to run tests locally with Python 3 (3.7 in this example):
- Install required modules with
pip3.7 install pytest-xdist pytest-mock mock
- Run tests with
ansible-test units --python 3.7 tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py
- Install required modules with
- Carefully verify newly created golden output files!