1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/unit/plugins/modules/system/interfaces_file
patchback[bot] 203747027e
Move licenses to LICENSES/, run add-license.py, add LICENSES/MIT.txt (#5065) (#5068)
* Move licenses to LICENSES/, run add-license.py, add LICENSES/MIT.txt.

* Replace 'Copyright:' with 'Copyright'

sed -i 's|Copyright:\(.*\)|Copyright\1|' $(rg -l 'Copyright:')

Co-authored-by: Maxwell G <gotmax@e.email>
(cherry picked from commit 123c7efe5e)

Co-authored-by: Felix Fontein <felix@fontein.de>
2022-08-05 13:17:19 +02:00
..
fixtures interfaces_file: unit tests improved (#3863) 2021-12-08 12:31:12 +01:00
__init__.py Move modules and module_utils unit tests to correct place (#81) 2020-03-31 10:42:38 +02:00
README.md Misc. typo fixes (#4940) (#4942) 2022-07-11 22:18:22 +02:00
test_interfaces_file.py Move licenses to LICENSES/, run add-license.py, add LICENSES/MIT.txt (#5065) (#5068) 2022-08-05 13:17:19 +02:00

interfaces_file unit tests

Tests structure

  • input directory contains interfaces configuration files
  • test_interfaces_file.py runs each hardcoded test against all configurations in input directory and compares results with golden outputs in golden_output

Running unit tests with docker

  1. Clone project to ansible_collections/community/general
  2. Change directory to the project one cd ansible_collections/community/general
  3. Run ansible-test units --docker -v --python 3.6 tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py

Adding tests

  1. New configurations should added to input directory
  2. New test cases should be defined in test_interfaces_file.py. Same for new test functions if needed
  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 (3.7 in this example):
    1. Install required modules with pip3.7 install pytest-xdist pytest-mock mock
    2. Run tests with ansible-test units --python 3.7 tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py
  4. Carefully verify newly created golden output files!