mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Update failed_when integration test to be more thorough
This commit is contained in:
parent
423f1233c8
commit
d913f169a8
1 changed files with 48 additions and 7 deletions
|
@ -16,13 +16,54 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- name: Test failed_when behavior but catch it.
|
- name: command rc 0 failed_when_result undef
|
||||||
command: /bin/true
|
shell: exit 0
|
||||||
failed_when: 2 != 3
|
|
||||||
register: failed
|
|
||||||
ignore_errors: True
|
ignore_errors: True
|
||||||
|
register: result
|
||||||
|
|
||||||
- name: Assert that failed_when is true.
|
- assert:
|
||||||
assert:
|
|
||||||
that:
|
that:
|
||||||
- "failed.failed_when_result == True"
|
- "'failed' not in result"
|
||||||
|
|
||||||
|
- name: command rc 0 failed_when_result False
|
||||||
|
shell: exit 0
|
||||||
|
failed_when: false
|
||||||
|
ignore_errors: true
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "'failed' in result and not result.failed"
|
||||||
|
- "'failed_when_result' in result and not result.failed_when_result"
|
||||||
|
|
||||||
|
- name: command rc 1 failed_when_result True
|
||||||
|
shell: exit 1
|
||||||
|
failed_when: true
|
||||||
|
ignore_errors: true
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "'failed' in result and result.failed"
|
||||||
|
- "'failed_when_result' in result and result.failed_when_result"
|
||||||
|
|
||||||
|
- name: command rc 1 failed_when_result undef
|
||||||
|
shell: exit 1
|
||||||
|
ignore_errors: true
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "'failed' not in result"
|
||||||
|
|
||||||
|
- name: command rc 1 failed_when_result False
|
||||||
|
shell: exit 1
|
||||||
|
failed_when: false
|
||||||
|
ignore_errors: true
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "'failed' in result and not result.failed"
|
||||||
|
- "'failed_when_result' in result and not result.failed_when_result"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue