mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add spm -y and -f arg integration tests
This commit is contained in:
parent
4643a112e7
commit
61ac5cf157
2 changed files with 60 additions and 5 deletions
|
@ -2,12 +2,13 @@
|
|||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.support.case import ShellCase,SPMCase
|
||||
|
||||
|
||||
class SPMTest(ShellCase):
|
||||
class SPMTest(ShellCase, SPMCase):
|
||||
'''
|
||||
Test spm script
|
||||
'''
|
||||
|
@ -29,3 +30,47 @@ class SPMTest(ShellCase):
|
|||
output = self.run_spm('doesnotexist')
|
||||
for arg in expected_args:
|
||||
self.assertIn(arg, ''.join(output))
|
||||
|
||||
def test_spm_assume_yes(self):
|
||||
'''
|
||||
test spm install with -y arg
|
||||
'''
|
||||
config = self._spm_config(assume_yes=False)
|
||||
self._spm_build_files(config)
|
||||
|
||||
spm_file = os.path.join(config['spm_build_dir'],
|
||||
'apache-201506-2.spm')
|
||||
|
||||
build = self.run_spm('build {0} -c {1}'.format(self.formula_dir,
|
||||
self._tmp_spm))
|
||||
|
||||
install = self.run_spm('install {0} -c {1} -y'.format(spm_file,
|
||||
self._tmp_spm))
|
||||
|
||||
self.assertTrue(os.path.exists(os.path.join(config['formula_path'],
|
||||
'apache', 'apache.sls')))
|
||||
|
||||
def test_spm_force(self):
|
||||
'''
|
||||
test spm install with -f arg
|
||||
'''
|
||||
config = self._spm_config(assume_yes=False)
|
||||
self._spm_build_files(config)
|
||||
|
||||
spm_file = os.path.join(config['spm_build_dir'],
|
||||
'apache-201506-2.spm')
|
||||
|
||||
build = self.run_spm('build {0} -c {1}'.format(self.formula_dir,
|
||||
self._tmp_spm))
|
||||
|
||||
install = self.run_spm('install {0} -c {1} -y'.format(spm_file,
|
||||
self._tmp_spm))
|
||||
|
||||
self.assertTrue(os.path.exists(os.path.join(config['formula_path'],
|
||||
'apache', 'apache.sls')))
|
||||
|
||||
# check if it forces the install after its already been installed it
|
||||
install = self.run_spm('install {0} -c {1} -y -f'.format(spm_file,
|
||||
self._tmp_spm))
|
||||
|
||||
self.assertEqual(['... installing apache'], install)
|
||||
|
|
|
@ -628,7 +628,7 @@ class SPMCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
|||
description: Formula for installing Apache
|
||||
'''))
|
||||
|
||||
def _spm_config(self):
|
||||
def _spm_config(self, assume_yes=True):
|
||||
self._tmp_spm = tempfile.mkdtemp()
|
||||
config = self.get_temp_config('minion', **{
|
||||
'spm_logfile': os.path.join(self._tmp_spm, 'log'),
|
||||
|
@ -641,10 +641,10 @@ class SPMCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
|||
'spm_db': os.path.join(self._tmp_spm, 'packages.db'),
|
||||
'extension_modules': os.path.join(self._tmp_spm, 'modules'),
|
||||
'file_roots': {'base': [self._tmp_spm, ]},
|
||||
'formula_path': os.path.join(self._tmp_spm, 'spm'),
|
||||
'formula_path': os.path.join(self._tmp_spm, 'salt'),
|
||||
'pillar_path': os.path.join(self._tmp_spm, 'pillar'),
|
||||
'reactor_path': os.path.join(self._tmp_spm, 'reactor'),
|
||||
'assume_yes': True,
|
||||
'assume_yes': True if assume_yes else False,
|
||||
'force': False,
|
||||
'verbose': False,
|
||||
'cache': 'localfs',
|
||||
|
@ -652,6 +652,16 @@ class SPMCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
|||
'spm_repo_dups': 'ignore',
|
||||
'spm_share_dir': os.path.join(self._tmp_spm, 'share'),
|
||||
})
|
||||
|
||||
import salt.utils
|
||||
import yaml
|
||||
|
||||
if not os.path.isdir(config['formula_path']):
|
||||
os.makedirs(config['formula_path'])
|
||||
|
||||
with salt.utils.fopen(os.path.join(self._tmp_spm, 'spm'), 'w') as fp:
|
||||
fp.write(yaml.dump(config))
|
||||
|
||||
return config
|
||||
|
||||
def _spm_create_update_repo(self, config):
|
||||
|
|
Loading…
Add table
Reference in a new issue