mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Updated test cases to include environment selection in states using __env__
.
This commit is contained in:
parent
f9fca9b809
commit
c170d1e572
@ -370,6 +370,7 @@ fi
|
||||
'state.highstate', minion_tgt='sub_minion'
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
self.assertTrue(os.path.isfile(tgt))
|
||||
with salt.utils.fopen(tgt, 'r') as cheese:
|
||||
data = cheese.read()
|
||||
self.assertIn('Gromit', data)
|
||||
|
@ -267,6 +267,22 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
|
||||
if os.path.isdir(name):
|
||||
shutil.rmtree(name, ignore_errors=True)
|
||||
|
||||
def test_recurse_specific_env(self):
|
||||
'''
|
||||
file.recurse passing __env__
|
||||
'''
|
||||
name = os.path.join(integration.TMP, 'recurse_dir_prod_env')
|
||||
ret = self.run_state('file.recurse',
|
||||
name=name,
|
||||
source='salt://holy',
|
||||
__env__='prod')
|
||||
try:
|
||||
self.assertSaltTrueReturn(ret)
|
||||
self.assertTrue(os.path.isfile(os.path.join(name, '32', 'scene')))
|
||||
finally:
|
||||
if os.path.isdir(name):
|
||||
shutil.rmtree(name, ignore_errors=True)
|
||||
|
||||
def test_test_recurse(self):
|
||||
'''
|
||||
file.recurse test interface
|
||||
@ -279,6 +295,21 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
|
||||
self.assertFalse(os.path.isfile(os.path.join(name, '36', 'scene')))
|
||||
self.assertFalse(os.path.exists(name))
|
||||
|
||||
def test_test_recurse_specific_env(self):
|
||||
'''
|
||||
file.recurse test interface
|
||||
'''
|
||||
name = os.path.join(integration.TMP, 'recurse_test_dir_prod_env')
|
||||
ret = self.run_state('file.recurse',
|
||||
test=True,
|
||||
name=name,
|
||||
source='salt://holy',
|
||||
__env__='prod'
|
||||
)
|
||||
self.assertSaltNoneReturn(ret)
|
||||
self.assertFalse(os.path.isfile(os.path.join(name, '32', 'scene')))
|
||||
self.assertFalse(os.path.exists(name))
|
||||
|
||||
def test_recurse_template(self):
|
||||
'''
|
||||
file.recurse with jinja template enabled
|
||||
@ -320,6 +351,33 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
|
||||
finally:
|
||||
shutil.rmtree(name, ignore_errors=True)
|
||||
|
||||
def test_recurse_clean_specific_env(self):
|
||||
'''
|
||||
file.recurse with clean=True and __env__=prod
|
||||
'''
|
||||
name = os.path.join(integration.TMP, 'recurse_clean_dir_prod_env')
|
||||
if not os.path.isdir(name):
|
||||
os.makedirs(name)
|
||||
strayfile = os.path.join(name, 'strayfile')
|
||||
salt.utils.fopen(strayfile, 'w').close()
|
||||
|
||||
# Corner cases: replacing file with a directory and vice versa
|
||||
salt.utils.fopen(os.path.join(name, '32'), 'w').close()
|
||||
os.makedirs(os.path.join(name, 'scene34'))
|
||||
ret = self.run_state('file.recurse',
|
||||
name=name,
|
||||
source='salt://holy',
|
||||
clean=True,
|
||||
__env__='prod')
|
||||
try:
|
||||
self.assertSaltTrueReturn(ret)
|
||||
self.assertFalse(os.path.exists(strayfile))
|
||||
self.assertTrue(os.path.isfile(os.path.join(name, '32', 'scene')))
|
||||
self.assertTrue(os.path.isfile(os.path.join(name, 'scene34')))
|
||||
finally:
|
||||
shutil.rmtree(name, ignore_errors=True)
|
||||
|
||||
|
||||
def test_replace(self):
|
||||
'''
|
||||
file.replace
|
||||
|
Loading…
Reference in New Issue
Block a user