use fun_function to call cmd.run

This commit is contained in:
Tyler Johnson 2019-10-15 21:04:57 -06:00
parent 4d150adc39
commit a3dc2b563f
No known key found for this signature in database
GPG Key ID: 691E31397E27D004

View File

@ -44,8 +44,7 @@ class NpmStateTest(ModuleCase, SaltReturnAssertsMixin):
'''
Determine if URL-referenced NPM module can be successfully installed.
'''
npm_bin = salt.utils.path.which('npm')
npm_version = cmd.run('{} -v'.format(npm_bin), timeout=10)
npm_version = self.run_function('cmd.run', ['npm -v'])
if LooseVersion(npm_version) >= LooseVersion(MAX_NPM_VERSION):
user = os.environ.get('SUDO_USER', 'root')
npm_dir = os.path.join(RUNTIME_VARS.TMP, 'git-install-npm')
@ -74,12 +73,13 @@ class NpmStateTest(ModuleCase, SaltReturnAssertsMixin):
ret = self.run_state('npm.installed', name='unused', pkgs=['pm2@2.10.4', 'grunt@1.0.2'], registry="http://registry.npmjs.org/")
self.assertSaltTrueReturn(ret)
@skipIf(salt.utils.path.which('npm') and LooseVersion(cmd.run('npm -v')) >= LooseVersion(MAX_NPM_VERSION),
'Skip with npm >= 5.0.0 until #41770 is fixed')
@destructiveTest
def test_npm_cache_clean(self):
'''
Basic test to determine if NPM successfully cleans its cached packages.
'''
npm_version = self.run_function('cmd.run', ['npm -v'])
if LooseVersion(npm_version) >= LooseVersion(MAX_NPM_VERSION):
self.skipTest('Skip with npm >= 5.0.0 until #41770 is fixed')
ret = self.run_state('npm.cache_cleaned', name='unused', force=True)
self.assertSaltTrueReturn(ret)