mirror of
https://github.com/linux-system-roles/network.git
synced 2026-07-20 01:45:09 +00:00
test: add test_unit.yml to run unit tests
This requires to make "library/network_connections.py" more independent from ansible modules In the end, the Python code runs on the target machines, with the python installed there. So, it makes sense to also run the unit tests as part of the CI tests.
This commit is contained in:
parent
16f3bb77f0
commit
03ff040df7
1 changed files with 34 additions and 0 deletions
34
test/test_unit.yml
Normal file
34
test/test_unit.yml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
- hosts: all
|
||||
name: execute python unit tests
|
||||
tasks:
|
||||
- copy:
|
||||
src: /role/library/network_connections.py
|
||||
dest: /tmp/test-unit-1/
|
||||
|
||||
- copy:
|
||||
src: /role/library/test_network_connections.py
|
||||
dest: /tmp/test-unit-1/
|
||||
|
||||
|
||||
- package:
|
||||
name: python2
|
||||
state: present
|
||||
ignore_errors: true
|
||||
register: python2_available
|
||||
|
||||
- command: python2 /tmp/test-unit-1/test_network_connections.py
|
||||
when: python2_available | succeeded
|
||||
|
||||
|
||||
- package:
|
||||
name: python3
|
||||
state: present
|
||||
ignore_errors: true
|
||||
register: python3_available
|
||||
|
||||
- command: python3 /tmp/test-unit-1/test_network_connections.py
|
||||
when: python3_available | succeeded
|
||||
|
||||
|
||||
- command: python /tmp/test-unit-1/test_network_connections.py
|
||||
Loading…
Add table
Add a link
Reference in a new issue