mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
c344d20a9a
* interfaces_file: fixed unit tests and added README, added test cases for #3862
* typo fix for interfaces_file unit tests README.md
Co-authored-by: Felix Fontein <felix@fontein.de>
* typo fix for interfaces_file unit tests README.md
Co-authored-by: Felix Fontein <felix@fontein.de>
* typo fix for interfaces_file unit tests README.md
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit
|
||
---|---|---|
.. | ||
fixtures | ||
__init__.py | ||
README.md | ||
test_interfaces_file.py |
interfaces_file unit tests
Tests structure
input
directory contains interfaces configuration filestest_interfaces_file.py
runs each hardcoded test agains 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!