summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/json_cleanup
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/json_cleanup')
-rw-r--r--test/integration/targets/json_cleanup/aliases2
-rw-r--r--test/integration/targets/json_cleanup/library/bad_json11
-rw-r--r--test/integration/targets/json_cleanup/module_output_cleaning.yml26
-rwxr-xr-xtest/integration/targets/json_cleanup/runme.sh5
4 files changed, 44 insertions, 0 deletions
diff --git a/test/integration/targets/json_cleanup/aliases b/test/integration/targets/json_cleanup/aliases
new file mode 100644
index 0000000..498fedd
--- /dev/null
+++ b/test/integration/targets/json_cleanup/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+context/controller
diff --git a/test/integration/targets/json_cleanup/library/bad_json b/test/integration/targets/json_cleanup/library/bad_json
new file mode 100644
index 0000000..1df8c72
--- /dev/null
+++ b/test/integration/targets/json_cleanup/library/bad_json
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+set -eu
+
+echo 'this stuff should be ignored'
+
+echo '[ looks like a json list]'
+
+echo '{"changed": false, "failed": false, "msg": "good json response"}'
+
+echo 'moar garbage'
diff --git a/test/integration/targets/json_cleanup/module_output_cleaning.yml b/test/integration/targets/json_cleanup/module_output_cleaning.yml
new file mode 100644
index 0000000..165352a
--- /dev/null
+++ b/test/integration/targets/json_cleanup/module_output_cleaning.yml
@@ -0,0 +1,26 @@
+- name: ensure we clean module output well
+ hosts: localhost
+ gather_facts: false
+ tasks:
+ - name: call module that spews extra stuff
+ bad_json:
+ register: clean_json
+ ignore_errors: true
+
+ - name: all expected is there
+ assert:
+ that:
+ - clean_json is success
+ - clean_json is not changed
+ - "clean_json['msg'] == 'good json response'"
+
+ - name: all non wanted is not there
+ assert:
+ that:
+ - item not in clean_json.values()
+ loop:
+ - this stuff should be ignored
+ - [ looks like a json list]
+ - '[ looks like a json list]'
+ - ' looks like a json list'
+ - moar garbage
diff --git a/test/integration/targets/json_cleanup/runme.sh b/test/integration/targets/json_cleanup/runme.sh
new file mode 100755
index 0000000..2de3bd0
--- /dev/null
+++ b/test/integration/targets/json_cleanup/runme.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook module_output_cleaning.yml "$@"