1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/npm/tasks/test.yml
patchback[bot] 42cc5280d9
[PR #6848/11406715 backport][stable-7] npm: replace test with required_if (#6856)
npm: replace test with required_if (#6848)

* npm: replace test with required_if

* add changelog frag

(cherry picked from commit 11406715f5)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
2023-07-06 06:42:25 +02:00

65 lines
1.6 KiB
YAML

---
# Copyright (c) Ansible Project
# 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
- name: 'Remove any node modules'
file:
path: '{{ remote_dir }}/node_modules'
state: absent
- vars:
# sample: node-v8.2.0-linux-x64.tar.xz
node_path: '{{ remote_dir }}/{{ nodejs_path }}/bin'
package: 'iconv-lite'
environment:
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
block:
- shell: npm --version
register: npm_version
- debug:
var: npm_version.stdout
- name: 'Install simple package without dependency'
npm:
path: '{{ remote_dir }}'
state: present
name: '{{ package }}'
register: npm_install
- assert:
that:
- npm_install is success
- npm_install is changed
- name: 'Reinstall simple package without dependency'
npm:
path: '{{ remote_dir }}'
state: present
name: '{{ package }}'
register: npm_reinstall
- name: Check there is no change
assert:
that:
- npm_reinstall is success
- not (npm_reinstall is changed)
- name: 'Manually delete package'
file:
path: '{{ remote_dir }}/node_modules/{{ package }}'
state: absent
- name: 'reinstall simple package'
npm:
path: '{{ remote_dir }}'
state: present
name: '{{ package }}'
register: npm_fix_install
- name: Check result is changed and successful
assert:
that:
- npm_fix_install is success
- npm_fix_install is changed