From 7348a613bbd51652862a99a1ae47090e762750b7 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Mon, 19 Jun 2017 01:58:33 +0530 Subject: [PATCH] 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 --- lib/ansible/modules/source_control/hg.py | 2 +- test/integration/targets/hg/tasks/main.yml | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/source_control/hg.py b/lib/ansible/modules/source_control/hg.py index 7c538e6b4e9..9cb9e979827 100644 --- a/lib/ansible/modules/source_control/hg.py +++ b/lib/ansible/modules/source_control/hg.py @@ -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') diff --git a/test/integration/targets/hg/tasks/main.yml b/test/integration/targets/hg/tasks/main.yml index 03b3458ede6..f9c1b1494bf 100644 --- a/test/integration/targets/hg/tasks/main.yml +++ b/test/integration/targets/hg/tasks/main.yml @@ -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"