1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-06-27 14:43:29 +00:00
community.general/tests/unit/plugins/modules/test_composer.yaml
Felix Fontein 2354b40d10
composer: restore compatibility with older composer versions (#12339)
* Restore compatibility.

* Adjust tests.
2026-06-25 05:33:40 +02:00

124 lines
3.4 KiB
YAML

# 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:
help_install: &help_install
command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "help", "install", "--no-interaction", "--format=json"]
rc: 0
out: |
{"definition": {"options": ["a", "b", "c"]}}
err: ''
help_create_project: &help_create_project
command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "help", "create-project", "--no-interaction", "--format=json"]
rc: 0
out: |
{"definition": {"options": ["a", "b", "c"]}}
err: ''
run_create_project: &run_create_project
command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "create-project", "vendor/package"]
rc: 0
out: ''
err: ''
help_config: &help_config
command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "help", "config", "--no-interaction", "--format=json"]
rc: 0
out: |
{"definition": {"options": ["a", "b", "c"]}}
err: ''
test_cases:
- id: composer
input:
command: install
working_dir: "/var/www/foo"
output:
changed: true
mocks:
run_command:
- *help_install
- command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "install"]
rc: 0
out: ''
err: ''
- id: create_project_runs
input:
command: create-project
arguments: "vendor/package"
working_dir: "/var/www/foo"
output:
changed: true
mocks:
os_path_exists:
return_value: false
run_command:
- *help_create_project
- *run_create_project
- id: create_project_skips_when_exists
input:
command: create-project
arguments: "vendor/package"
working_dir: "/var/www/foo"
output:
changed: false
mocks:
os_path_exists:
return_value: true
run_command:
- *help_create_project
- id: create_project_force
input:
command: create-project
arguments: "vendor/package"
working_dir: "/var/www/foo"
force: true
output:
changed: true
mocks:
os_path_exists:
return_value: true
run_command:
- *help_create_project
- *run_create_project
- id: config_no_change
input:
command: config
arguments: "setting-key setting-value"
working_dir: "/var/www/foo"
output:
changed: false
mocks:
os_path_isfile:
return_value: true
sha256:
return_values: ["hash1", "hash2", "hash1", "hash2"]
run_command:
- *help_config
- command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "config", "setting-key", "setting-value"]
rc: 0
out: ''
err: ''
- id: config_changed
input:
command: config
arguments: "setting-key setting-value"
working_dir: "/var/www/foo"
output:
changed: true
mocks:
os_path_isfile:
return_value: true
sha256:
return_values: ["hash1", "hash2", "hash1_changed", "hash2"]
run_command:
- *help_config
- command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "config", "setting-key", "setting-value"]
rc: 0
out: ''
err: ''