From 12774729c018ec8f7fae2b420961836dd7e89c5c Mon Sep 17 00:00:00 2001 From: Giorgos Drosos Date: Thu, 24 Jul 2025 12:53:39 +0300 Subject: [PATCH] Remove redundant conditional --- plugins/modules/apk.py | 5 +---- tests/integration/targets/apk/tasks/main.yml | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/plugins/modules/apk.py b/plugins/modules/apk.py index 6f1d979e00..499fc78ff6 100644 --- a/plugins/modules/apk.py +++ b/plugins/modules/apk.py @@ -372,10 +372,7 @@ def main(): upgrade_packages(module, p['available']) if all(not name.strip() for name in p['name']): - if len(p['name']) == 1: - module.fail_json(msg="Package name cannot be empty or whitespace-only") - else: - module.fail_json(msg="Package names cannot be empty or whitespace-only") + module.fail_json(msg="Package name(s) cannot be empty or whitespace-only") if p['state'] in ['present', 'latest']: install_packages(module, p['name'], p['state'], p['world']) diff --git a/tests/integration/targets/apk/tasks/main.yml b/tests/integration/targets/apk/tasks/main.yml index c8debeb300..a2657d1ec1 100644 --- a/tests/integration/targets/apk/tasks/main.yml +++ b/tests/integration/targets/apk/tasks/main.yml @@ -169,7 +169,7 @@ ansible.builtin.assert: that: - result_empty is failed - - "'Package name cannot be empty' in result_empty.msg" + - "'Package name(s) cannot be empty' in result_empty.msg" - name: Install package name with only spaces community.general.apk: @@ -181,7 +181,7 @@ ansible.builtin.assert: that: - result_spaces is failed - - "'Package name cannot be empty' in result_spaces.msg" + - "'Package name(s) cannot be empty' in result_spaces.msg" - name: Accept list with valid and empty string community.general.apk: @@ -204,5 +204,5 @@ ansible.builtin.assert: that: - result_multiple_empty is failed - - "'All package names are empty or whitespace' in result_multiple_empty.msg" + - "'Package name(s) cannot be empty' in result_multiple_empty.msg" ignore_errors: true \ No newline at end of file