mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
npm - fix installing from package.json (#2924)
correctly handle cases where a dependency does not have a `version` property because it is either missing or invalid
This commit is contained in:
parent
ffe505a798
commit
a0915036f9
3 changed files with 25 additions and 2 deletions
|
@ -52,6 +52,25 @@ class NPMModuleTestCase(ModuleTestCase):
|
|||
call(['/testbin/npm', 'install', '--global', 'coffee-script'], check_rc=True, cwd=None),
|
||||
])
|
||||
|
||||
def test_present_missing(self):
|
||||
set_module_args({
|
||||
'name': 'coffee-script',
|
||||
'global': 'true',
|
||||
'state': 'present',
|
||||
})
|
||||
self.module_main_command.side_effect = [
|
||||
(0, '{"dependencies": {"coffee-script": {"missing" : true}}}', ''),
|
||||
(0, '{}', ''),
|
||||
]
|
||||
|
||||
result = self.module_main(AnsibleExitJson)
|
||||
|
||||
self.assertTrue(result['changed'])
|
||||
self.module_main_command.assert_has_calls([
|
||||
call(['/testbin/npm', 'list', '--json', '--long', '--global'], check_rc=False, cwd=None),
|
||||
call(['/testbin/npm', 'install', '--global', 'coffee-script'], check_rc=True, cwd=None),
|
||||
])
|
||||
|
||||
def test_present_version(self):
|
||||
set_module_args({
|
||||
'name': 'coffee-script',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue