From e1a33a6a84774c568285e0b6090655e1473fbef7 Mon Sep 17 00:00:00 2001 From: Rick Elrod Date: Wed, 15 Jul 2020 11:31:48 -0500 Subject: [PATCH] inventory_hostnames lookup plugin -> 100% coverage (#70628) Change: - Add tests to get inventory_hostnames up to 100% coverage. Test Plan: - CI Signed-off-by: Rick Elrod --- .../targets/lookup_inventory_hostnames/inventory | 12 ++++++++++++ .../targets/lookup_inventory_hostnames/main.yml | 12 ++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/test/integration/targets/lookup_inventory_hostnames/inventory b/test/integration/targets/lookup_inventory_hostnames/inventory index 1b968af2991..ca7234f7e08 100644 --- a/test/integration/targets/lookup_inventory_hostnames/inventory +++ b/test/integration/targets/lookup_inventory_hostnames/inventory @@ -1,6 +1,18 @@ +nogroup01 +nogroup02 +nogroup03 + [group01] test01 test05 test03 test02 test04 + +[group02] +test03 +test04 +test200 +test201 +test203 +test204 diff --git a/test/integration/targets/lookup_inventory_hostnames/main.yml b/test/integration/targets/lookup_inventory_hostnames/main.yml index afc09ea86e3..820d37d25b0 100644 --- a/test/integration/targets/lookup_inventory_hostnames/main.yml +++ b/test/integration/targets/lookup_inventory_hostnames/main.yml @@ -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