Skip to content

Commit

Permalink
Test that the role fails, not that it sets blivet_output.failed
Browse files Browse the repository at this point in the history
The latter would be a valid test as well, but a less important one, and
currently it does not work properly.

Do not use ignore_errors: yes on the test block, it makes all assert
pointless. Use a rescue task instead.
  • Loading branch information
pcahyna committed Oct 15, 2019
1 parent 1e3f2c9 commit 611553a
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions tests/tests_disk_errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,31 @@
disks: ['/dev/surelyidonotexist']
mount_point: "{{ mount_location }}"

- name: Check the error output
- name: UNREACH
fail:
msg: "this should be unreachable"

rescue:
- name: Check that we failed in the role
assert:
that: "{{ blivet_output.failed }}"
msg: "Expected error message not found for missing disk"
ignore_errors: yes
that:
- ansible_failed_task.name != 'UNREACH'
msg: "Role has not failed when it should have"
vars:
# Ugh! needed to expand ansible_failed_task
storage_provider: blivet

# the following does not work properly,
# blivet_output.failed is false.
# - name: Show the error output
# debug:
# msg: "{{ blivet_output.failed }}"

# - name: Check the error output
# assert:
# that: blivet_output.failed | bool
# msg: "Expected error message not found for missing disk"


- name: Test for correct handling of safe_mode
block:
Expand Down

0 comments on commit 611553a

Please sign in to comment.