mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Correct usage of fail_json in hg module (#25847)
Fix adds correct usage for fail_json and also adds testcases to verify this. Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
561d678f52
commit
7348a613bb
2 changed files with 13 additions and 1 deletions
|
@ -157,7 +157,7 @@ class Hg(object):
|
||||||
def get_remote_revision(self):
|
def get_remote_revision(self):
|
||||||
(rc, out, err) = self._command(['id', self.repo])
|
(rc, out, err) = self._command(['id', self.repo])
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.module_fail_json(msg=err)
|
self.module.fail_json(msg=err)
|
||||||
else:
|
else:
|
||||||
return to_native(out).strip('\n')
|
return to_native(out).strip('\n')
|
||||||
|
|
||||||
|
|
|
@ -72,3 +72,15 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "not hg_result2.changed"
|
- "not hg_result2.changed"
|
||||||
|
|
||||||
|
- name: Checkout non-existent repo clone
|
||||||
|
hg: repo=https://bitbucket.org/pyro46/pythonscript_1 clone=no update=no
|
||||||
|
register: hg_result3
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Verify result of non-existent repo clone
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- hg_result3.msg
|
||||||
|
- "'abort: HTTP Error 404: Not Found' in hg_result3.msg"
|
||||||
|
- "not hg_result3.changed"
|
||||||
|
|
Loading…
Reference in a new issue