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:
Abhijeet Kasurde 2017-06-19 01:58:33 +05:30 committed by René Moser
parent 561d678f52
commit 7348a613bb
2 changed files with 13 additions and 1 deletions

View file

@ -157,7 +157,7 @@ class Hg(object):
def get_remote_revision(self):
(rc, out, err) = self._command(['id', self.repo])
if rc != 0:
self.module_fail_json(msg=err)
self.module.fail_json(msg=err)
else:
return to_native(out).strip('\n')

View file

@ -72,3 +72,15 @@
assert:
that:
- "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"