Skip to content

Commit

Permalink
Fix diy callback tests. (#841) (#906)
Browse files Browse the repository at this point in the history
(cherry picked from commit e5d15a5)

Co-authored-by: Felix Fontein <[email protected]>
  • Loading branch information
patchback[bot] and felixfontein authored Sep 17, 2020
1 parent 869e0e6 commit 25eabb3
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions tests/integration/targets/callback_diy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@
"\u001b[0;32mok: [testhost] => (item=sample item 3) => {\u001b[0m",
"\u001b[0;32m \"msg\": \"sample debug msg sample item 3\"\u001b[0m",
"\u001b[0;32m}\u001b[0m",
"\u001b[0;31mfatal: [testhost]: FAILED! => {\"msg\": \"All items completed\"}\u001b[0m",
[
# Apparently a bug was fixed in Ansible, as before it ran through with "All items completed"
"\u001b[0;31mfatal: [testhost]: FAILED! => {\"msg\": \"All items completed\"}\u001b[0m",
"\u001b[0;31mfatal: [testhost]: FAILED! => {\"msg\": \"One or more items failed\"}\u001b[0m",
],
"\u001b[0;36m...ignoring\u001b[0m",
"",
"PLAY RECAP *********************************************************************",
Expand Down Expand Up @@ -491,7 +495,7 @@

- name: Assert test output equals expected output
assert:
that: result.output.got == result.output.expected
that: result.output.differences | length == 0
loop: "{{ results }}"
loop_control:
loop_var: result
Expand All @@ -504,13 +508,22 @@
{%- set differences = [] -%}
{%- for i in range([result.test.expected_output | count, result.stdout_lines | count] | max) -%}
{%- set line = "line_%s" | format(i+1) -%}
{%- set expected_line = result.test.expected_output[i] | default(none) -%}
{%- set test_line = result.stdout_lines[i] | default(none) -%}
{%- if expected_line != test_line -%}
{{- differences.append({
line: {
'expected': expected_line,
'got': test_line }}) -}}
{%- set expected_lines = result.test.expected_output[i] | default(none) -%}
{%- if expected_lines is not string -%}
{%- if test_line not in expected_lines -%}
{{- differences.append({
line: {
'expected_one_of': expected_lines,
'got': test_line }}) -}}
{%- endif -%}
{%- else -%}
{%- if expected_lines != test_line -%}
{{- differences.append({
line: {
'expected': expected_line,
'got': test_line }}) -}}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{{- results.append({
Expand Down

0 comments on commit 25eabb3

Please sign in to comment.