| 1 |
# Copyright (c) 2026 Alexei Znamensky ([email protected]) |
| 2 |
# Copyright (c) 2021 Abhijeet Kasurde <[email protected]> |
| 3 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
|
| 6 |
--- |
| 7 |
anchors: |
| 8 |
env_list: &env-list {check_rc: false, cwd: null, environ_update: {LANGUAGE: C, LC_ALL: C}} |
| 9 |
env_exec: &env-exec {check_rc: true, cwd: null, environ_update: {LANGUAGE: C, LC_ALL: C}} |
| 10 |
|
| 11 |
test_cases: |
| 12 |
- id: present |
| 13 |
input: |
| 14 |
name: coffee-script |
| 15 |
global: true |
| 16 |
state: present |
| 17 |
output: |
| 18 |
changed: true |
| 19 |
mocks: |
| 20 |
run_command: |
| 21 |
- command: [/testbin/npm, list, --json, --long, --global] |
| 22 |
environ: *env-list |
| 23 |
rc: 0 |
| 24 |
out: '{}' |
| 25 |
err: '' |
| 26 |
- command: [/testbin/npm, install, --global, coffee-script] |
| 27 |
environ: *env-exec |
| 28 |
rc: 0 |
| 29 |
out: '{}' |
| 30 |
err: '' |
| 31 |
|
| 32 |
- id: present_missing |
| 33 |
input: |
| 34 |
name: coffee-script |
| 35 |
global: true |
| 36 |
state: present |
| 37 |
output: |
| 38 |
changed: true |
| 39 |
mocks: |
| 40 |
run_command: |
| 41 |
- command: [/testbin/npm, list, --json, --long, --global] |
| 42 |
environ: *env-list |
| 43 |
rc: 0 |
| 44 |
out: '{"dependencies": {"coffee-script": {"missing": true}}}' |
| 45 |
err: '' |
| 46 |
- command: [/testbin/npm, install, --global, coffee-script] |
| 47 |
environ: *env-exec |
| 48 |
rc: 0 |
| 49 |
out: '{}' |
| 50 |
err: '' |
| 51 |
|
| 52 |
- id: present_version |
| 53 |
input: |
| 54 |
name: coffee-script |
| 55 |
global: true |
| 56 |
state: present |
| 57 |
version: '2.5.1' |
| 58 |
output: |
| 59 |
changed: true |
| 60 |
mocks: |
| 61 |
run_command: |
| 62 |
- command: [/testbin/npm, list, --json, --long, --global] |
| 63 |
environ: *env-list |
| 64 |
rc: 0 |
| 65 |
out: '{}' |
| 66 |
err: '' |
| 67 |
- command: [/testbin/npm, install, --global, '[email protected]'] |
| 68 |
environ: *env-exec |
| 69 |
rc: 0 |
| 70 |
out: '{}' |
| 71 |
err: '' |
| 72 |
|
| 73 |
- id: present_version_update |
| 74 |
input: |
| 75 |
name: coffee-script |
| 76 |
global: true |
| 77 |
state: present |
| 78 |
version: '2.5.1' |
| 79 |
output: |
| 80 |
changed: true |
| 81 |
mocks: |
| 82 |
run_command: |
| 83 |
- command: [/testbin/npm, list, --json, --long, --global] |
| 84 |
environ: *env-list |
| 85 |
rc: 0 |
| 86 |
out: '{"dependencies": {"coffee-script": {"version": "2.5.0"}}}' |
| 87 |
err: '' |
| 88 |
- command: [/testbin/npm, install, --global, '[email protected]'] |
| 89 |
environ: *env-exec |
| 90 |
rc: 0 |
| 91 |
out: '{}' |
| 92 |
err: '' |
| 93 |
|
| 94 |
- id: present_version_exists |
| 95 |
input: |
| 96 |
name: coffee-script |
| 97 |
global: true |
| 98 |
state: present |
| 99 |
version: '2.5.1' |
| 100 |
output: |
| 101 |
changed: false |
| 102 |
mocks: |
| 103 |
run_command: |
| 104 |
- command: [/testbin/npm, list, --json, --long, --global] |
| 105 |
environ: *env-list |
| 106 |
rc: 0 |
| 107 |
out: '{"dependencies": {"coffee-script": {"version": "2.5.1"}}}' |
| 108 |
err: '' |
| 109 |
|
| 110 |
- id: absent |
| 111 |
input: |
| 112 |
name: coffee-script |
| 113 |
global: true |
| 114 |
state: absent |
| 115 |
output: |
| 116 |
changed: true |
| 117 |
mocks: |
| 118 |
run_command: |
| 119 |
- command: [/testbin/npm, list, --json, --long, --global] |
| 120 |
environ: *env-list |
| 121 |
rc: 0 |
| 122 |
out: '{"dependencies": {"coffee-script": {"version": "2.5.1"}}}' |
| 123 |
err: '' |
| 124 |
- command: [/testbin/npm, uninstall, --global, coffee-script] |
| 125 |
environ: *env-exec |
| 126 |
rc: 0 |
| 127 |
out: '{}' |
| 128 |
err: '' |
| 129 |
|
| 130 |
- id: absent_version |
| 131 |
input: |
| 132 |
name: coffee-script |
| 133 |
global: true |
| 134 |
state: absent |
| 135 |
version: '2.5.1' |
| 136 |
output: |
| 137 |
changed: true |
| 138 |
mocks: |
| 139 |
run_command: |
| 140 |
- command: [/testbin/npm, list, --json, --long, --global] |
| 141 |
environ: *env-list |
| 142 |
rc: 0 |
| 143 |
out: '{"dependencies": {"coffee-script": {"version": "2.5.1"}}}' |
| 144 |
err: '' |
| 145 |
- command: [/testbin/npm, uninstall, --global, coffee-script] |
| 146 |
environ: *env-exec |
| 147 |
rc: 0 |
| 148 |
out: '{}' |
| 149 |
err: '' |
| 150 |
|
| 151 |
- id: absent_version_different |
| 152 |
input: |
| 153 |
name: coffee-script |
| 154 |
global: true |
| 155 |
state: absent |
| 156 |
version: '2.5.1' |
| 157 |
output: |
| 158 |
changed: true |
| 159 |
mocks: |
| 160 |
run_command: |
| 161 |
- command: [/testbin/npm, list, --json, --long, --global] |
| 162 |
environ: *env-list |
| 163 |
rc: 0 |
| 164 |
out: '{"dependencies": {"coffee-script": {"version": "2.5.0"}}}' |
| 165 |
err: '' |
| 166 |
- command: [/testbin/npm, uninstall, --global, coffee-script] |
| 167 |
environ: *env-exec |
| 168 |
rc: 0 |
| 169 |
out: '{}' |
| 170 |
err: '' |
| 171 |
|
| 172 |
- id: present_package_json |
| 173 |
input: |
| 174 |
global: true |
| 175 |
state: present |
| 176 |
output: |
| 177 |
changed: true |
| 178 |
mocks: |
| 179 |
run_command: |
| 180 |
- command: [/testbin/npm, list, --json, --long, --global] |
| 181 |
environ: *env-list |
| 182 |
rc: 0 |
| 183 |
out: '{}' |
| 184 |
err: '' |
| 185 |
- command: [/testbin/npm, install, --global] |
| 186 |
environ: *env-exec |
| 187 |
rc: 0 |
| 188 |
out: '{}' |
| 189 |
err: '' |
| 190 |
|
| 191 |
- id: present_package_json_production |
| 192 |
input: |
| 193 |
production: true |
| 194 |
global: true |
| 195 |
state: present |
| 196 |
output: |
| 197 |
changed: true |
| 198 |
mocks: |
| 199 |
run_command: |
| 200 |
- command: [/testbin/npm, list, --json, --long, --global] |
| 201 |
environ: *env-list |
| 202 |
rc: 0 |
| 203 |
out: '{}' |
| 204 |
err: '' |
| 205 |
- command: [/testbin/npm, install, --global, --production] |
| 206 |
environ: *env-exec |
| 207 |
rc: 0 |
| 208 |
out: '{}' |
| 209 |
err: '' |
| 210 |
|
| 211 |
- id: present_package_json_ci |
| 212 |
input: |
| 213 |
ci: true |
| 214 |
global: true |
| 215 |
state: present |
| 216 |
output: |
| 217 |
changed: true |
| 218 |
mocks: |
| 219 |
run_command: |
| 220 |
- command: [/testbin/npm, ci, --global] |
| 221 |
environ: *env-exec |
| 222 |
rc: 0 |
| 223 |
out: '{}' |
| 224 |
err: '' |
| 225 |
|
| 226 |
- id: present_package_json_ci_production |
| 227 |
input: |
| 228 |
ci: true |
| 229 |
production: true |
| 230 |
global: true |
| 231 |
state: present |
| 232 |
output: |
| 233 |
changed: true |
| 234 |
mocks: |
| 235 |
run_command: |
| 236 |
- command: [/testbin/npm, ci, --global, --production] |
| 237 |
environ: *env-exec |
| 238 |
rc: 0 |
| 239 |
out: '{}' |
| 240 |
err: '' |