Debian Codegraph @

ansible_collections/community/general/tests/unit/plugins/modules/interfaces_file/interfaces_file-README.md

raw
1 <!--
2 Copyright (c) Ansible Project
3 GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 SPDX-License-Identifier: GPL-3.0-or-later
5 -->
6
7 # interfaces_file unit tests
8
9 ## Tests structure
10
11 - `input` directory contains interfaces configuration files
12 - `test_interfaces_file.py` runs each hardcoded test against all configurations in `input` directory and compares results with golden outputs in `golden_output`
13
14 ## Running unit tests with docker
15
16 1. Clone project to `ansible_collections/community/general`
17 2. Change directory to the project one `cd ansible_collections/community/general`
18 3. Run `ansible-test units --docker -v --python 3.14 tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py`
19
20 ## Adding tests
21
22 1. New configurations should added to `input` directory
23 2. New test cases should be defined in `test_interfaces_file.py`. Same for new test functions if needed
24 3. 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:
25 1. Install required modules with `pip install pytest-xdist pytest-mock mock`
26 2. Run tests with `ansible-test units --python 3.14 tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py`
27 4. Carefully verify newly created golden output files!