From 54014529bdd0c1d6d8332cb924bac53001483aa4 Mon Sep 17 00:00:00 2001 From: Jose Angel Munoz Date: Wed, 17 Jun 2020 17:39:24 +0200 Subject: [PATCH] Return correct values when running yarn in check mode (#153) * Fixes Check Mode * Adds parenthesis * Adds changelog and tests --- ...53-yarn_fix_checkmode-ec61975fc65df7f0.yaml | 3 +++ plugins/modules/packaging/language/yarn.py | 2 +- tests/integration/targets/yarn/tasks/run.yml | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/153-yarn_fix_checkmode-ec61975fc65df7f0.yaml diff --git a/changelogs/fragments/153-yarn_fix_checkmode-ec61975fc65df7f0.yaml b/changelogs/fragments/153-yarn_fix_checkmode-ec61975fc65df7f0.yaml new file mode 100644 index 0000000000..6544cf5763 --- /dev/null +++ b/changelogs/fragments/153-yarn_fix_checkmode-ec61975fc65df7f0.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: +- yarn - Return correct values when running yarn in check mode (https://github.com/ansible-collections/community.general/pull/153). diff --git a/plugins/modules/packaging/language/yarn.py b/plugins/modules/packaging/language/yarn.py index 3ab7dcfb76..6e2bbaa7c9 100644 --- a/plugins/modules/packaging/language/yarn.py +++ b/plugins/modules/packaging/language/yarn.py @@ -218,7 +218,7 @@ class Yarn(object): rc, out, err = self.module.run_command(cmd, check_rc=check_rc, cwd=cwd) return out, err - return '' + return(None, None) def list(self): cmd = ['list', '--depth=0', '--json'] diff --git a/tests/integration/targets/yarn/tasks/run.yml b/tests/integration/targets/yarn/tasks/run.yml index 37fb7acfbc..bd17d7ffeb 100644 --- a/tests/integration/targets/yarn/tasks/run.yml +++ b/tests/integration/targets/yarn/tasks/run.yml @@ -69,6 +69,24 @@ that: - not (yarn_install is changed) + - name: 'Install all packages in check mode.' + yarn: + path: '{{ output_dir }}' + executable: '{{ yarn_bin_path }}/yarn' + state: present + environment: + PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}' + check_mode: true + register: yarn_install_check + + - name: verify test yarn global installation in check mode + assert: + that: + - yarn_install_check.err is defined + - yarn_install_check.out is defined + - yarn_install_check.err is none + - yarn_install_check.out is none + - name: 'Install package with explicit version (older version of package)' yarn: path: '{{ output_dir }}'