Skip to content

Commit

Permalink
add interface_split and interface_range filter plugin tests (ansible-…
Browse files Browse the repository at this point in the history
…network#92)

Signed-off-by: Trishna Guha <[email protected]>
  • Loading branch information
trishnaguha authored Jun 6, 2018
1 parent a344ce3 commit 3ede6d7
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/interface_range/interface_range/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- ../../../network-engine
34 changes: 34 additions & 0 deletions tests/interface_range/interface_range/tasks/interface_range.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
- name: interface_range Ethernet1-3
debug:
msg: "{{ 'Ethernet1-3' | interface_range }}"
register: result

- assert:
that:
- "'Ethernet1' in result.msg"
- "'Ethernet2' in result.msg"
- "'Ethernet3' in result.msg"

- name: interface_range Ethernet1,3-4,5
debug:
msg: "{{ 'Ethernet1,3-4,5' | interface_range }}"
register: result

- assert:
that:
- "'Ethernet1' in result.msg"
- "'Ethernet3' in result.msg"
- "'Ethernet4' in result.msg"
- "'Ethernet5' in result.msg"

- name: interface_range Ethernet1/3-5,8
debug:
msg: "{{ 'Ethernet1/3-5,8' | interface_range }}"
register: result

- assert:
that:
- "'Ethernet1/3' in result.msg"
- "'Ethernet1/4' in result.msg"
- "'Ethernet1/5' in result.msg"
- "'Ethernet1/8' in result.msg"
3 changes: 3 additions & 0 deletions tests/interface_range/interface_range/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: interface_range test
import_tasks: interface_range.yaml
4 changes: 4 additions & 0 deletions tests/interface_range/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- hosts: localhost
connection: local
roles:
- interface_range
3 changes: 3 additions & 0 deletions tests/interface_split/interface_split/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- ../../../network-engine
27 changes: 27 additions & 0 deletions tests/interface_split/interface_split/tasks/interface_split.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- name: interface_split Ethernet1
debug:
msg: "{{ 'Ethernet1' | interface_split }}"
register: result

- assert:
that:
- "'1' in result.msg.index"
- "'Ethernet' in result.msg.name"

- name: interface_split Ethernet1 name
debug:
msg: "{{ 'Ethernet1' | interface_split('name') }}"
register: result

- assert:
that:
- "'Ethernet' in result.msg"

- name: interface_split Ethernet1 index
debug:
msg: "{{ 'Ethernet1' | interface_split('index') }}"
register: result

- assert:
that:
- "'1' in result.msg"
3 changes: 3 additions & 0 deletions tests/interface_split/interface_split/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: interface_split test
import_tasks: interface_split.yaml
4 changes: 4 additions & 0 deletions tests/interface_split/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- hosts: localhost
connection: local
roles:
- interface_split
2 changes: 2 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
- import_playbook: vlan_expand/test.yml
- import_playbook: netcfg_diff/test.yml
- import_playbook: yang2spec/test.yml
- import_playbook: interface_range/test.yml
- import_playbook: interface_split/test.yml

0 comments on commit 3ede6d7

Please sign in to comment.