forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not return the body even if it failed (ansible#69706)
* do not return the body even if it failed * add some tests for this and rebase * import test task * ignore_errors when fails Co-authored-by: Jack Zhang <[email protected]>
- Loading branch information
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bugfixes: | ||
- uri - Don't return the body even if it failed | ||
(https://github.com/ansible/ansible/issues/21003) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
- name: Test when return_content is yes | ||
uri: | ||
url: https://{{ httpbin_host }}/get | ||
return_content: yes | ||
register: result | ||
|
||
- name: Assert content exists when return_content is yes and request succeeds | ||
assert: | ||
that: | ||
- result is successful | ||
- "'content' in result" | ||
|
||
- name: Test when return_content is yes | ||
uri: | ||
url: http://does/not/exist | ||
return_content: yes | ||
register: result | ||
ignore_errors: true | ||
|
||
- name: Assert content exists when return_content is yes and request fails | ||
assert: | ||
that: | ||
- result is failed | ||
- "'content' in result" | ||
|
||
- name: Test when return_content is no | ||
uri: | ||
url: https://{{ httpbin_host }}/get | ||
return_content: no | ||
register: result | ||
|
||
- name: Assert content does not exist when return_content is no and request succeeds | ||
assert: | ||
that: | ||
- result is successful | ||
- "'content' not in result" | ||
|
||
- name: Test when return_content is no | ||
uri: | ||
url: http://does/not/exist | ||
return_content: no | ||
register: result | ||
ignore_errors: true | ||
|
||
- name: Assert content does not exist when return_content is no and request fails | ||
assert: | ||
that: | ||
- result is failed | ||
- "'content' not in result" |