mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-03 15:04:02 -07:00
[PR #10669/13bd4b5d backport][stable-11] composer: fix command args as list rather than string (#10680)
composer: fix command args as list rather than string (#10669)
(cherry picked from commit 13bd4b5d82
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
15109a26fd
commit
04305e8d9d
4 changed files with 59 additions and 9 deletions
17
tests/unit/plugins/modules/test_composer.py
Normal file
17
tests/unit/plugins/modules/test_composer.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Author: Alexei Znamensky (russoz@gmail.com)
|
||||
#
|
||||
# Copyright (c) Alexei Znamensky (russoz@gmail.com)
|
||||
#
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import composer
|
||||
from .uthelper import UTHelper, RunCommandMock
|
||||
|
||||
|
||||
UTHelper.from_module(composer, __name__, mocks=[RunCommandMock])
|
27
tests/unit/plugins/modules/test_composer.yaml
Normal file
27
tests/unit/plugins/modules/test_composer.yaml
Normal file
|
@ -0,0 +1,27 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) Alexei Znamensky (russoz@gmail.com)
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ_true: &env-def-true {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
environ_false: &env-def-false {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
test_cases:
|
||||
- id: composer
|
||||
input:
|
||||
command: install
|
||||
working_dir: "/var/www/foo"
|
||||
output:
|
||||
changed: true
|
||||
mocks:
|
||||
run_command:
|
||||
- command: ["/testbin/php", "/testbin/composer", "help", "install", "--working-dir", "/var/www/foo", "--no-interaction", "--format=json"]
|
||||
rc: 0
|
||||
out: |
|
||||
{"definition": {"options": ["a", "b", "c"]}}
|
||||
err: ''
|
||||
- command: ["/testbin/php", "/testbin/composer", "install", "--working-dir", "/var/www/foo"]
|
||||
rc: 0
|
||||
out: ''
|
||||
err: ''
|
|
@ -253,7 +253,7 @@ class RunCommandMock(TestCaseMock):
|
|||
|
||||
def check(self, test_case, results):
|
||||
call_args_list = [(item[0][0], item[1]) for item in self.mock_run_cmd.call_args_list]
|
||||
expected_call_args_list = [(item['command'], item['environ']) for item in self.mock_specs]
|
||||
expected_call_args_list = [(item['command'], item.get('environ', {})) for item in self.mock_specs]
|
||||
print("call args list =\n%s" % call_args_list)
|
||||
print("expected args list =\n%s" % expected_call_args_list)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue