Skip to content

Commit

Permalink
inventory_hostnames lookup plugin -> 100% coverage (ansible#70628)
Browse files Browse the repository at this point in the history
Change:
- Add tests to get inventory_hostnames up to 100% coverage.

Test Plan:
- CI

Signed-off-by: Rick Elrod <[email protected]>
  • Loading branch information
relrod authored Jul 15, 2020
1 parent 01e3099 commit e1a33a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 12 additions & 0 deletions test/integration/targets/lookup_inventory_hostnames/inventory
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
nogroup01
nogroup02
nogroup03

[group01]
test01
test05
test03
test02
test04

[group02]
test03
test04
test200
test201
test203
test204
12 changes: 10 additions & 2 deletions test/integration/targets/lookup_inventory_hostnames/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
tasks:
- set_fact:
hosts_a: "{{ lookup('inventory_hostnames', 'group01', wantlist=true) }}"

- set_fact:
hosts_b: "{{ groups['group01'] }}"
exclude: "{{ lookup('inventory_hostnames', 'group01:!test03', wantlist=true) }}"
intersect: "{{ lookup('inventory_hostnames', 'group01:&group02', wantlist=true) }}"
nogroup: "{{ lookup('inventory_hostnames', 'nogroup01', wantlist=true) }}"
doesnotexist: "{{ lookup('inventory_hostnames', 'doesnotexist', wantlist=true) }}"
all: "{{ lookup('inventory_hostnames', 'all', wantlist=true) }}"

- assert:
that:
- hosts_a == hosts_b
- "'test03' not in exclude"
- intersect == ['test03', 'test04']
- nogroup == ['nogroup01']
- doesnotexist == []
- all|length == 12

0 comments on commit e1a33a6

Please sign in to comment.