mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Correctly trigger the issue reported on #8196.
This commit is contained in:
parent
2924f1c14a
commit
ec76b188b1
3 changed files with 37 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
|||
/testfile:
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('testfile') }}:
|
||||
file:
|
||||
- managed
|
||||
- source: salt://testfile
|
||||
|
|
|
@ -277,23 +277,30 @@ class CPModuleTest(integration.ModuleCase):
|
|||
hashlib.md5(fn_.read()).hexdigest()
|
||||
)
|
||||
|
||||
def test_get_file_from_env(self):
|
||||
def test_get_file_from_env_predifined(self):
|
||||
'''
|
||||
cp.get_file
|
||||
'''
|
||||
tgt = os.path.join(integration.TMP, 'cheese')
|
||||
self.run_function('cp.get_file', ['salt://cheese', tgt])
|
||||
with salt.utils.fopen(tgt, 'r') as cheese:
|
||||
data = cheese.read()
|
||||
self.assertIn('Gromit', data)
|
||||
self.assertNotIn('Comte', data)
|
||||
|
||||
self.run_function('cp.get_file', ['salt://cheese?env=prod', tgt])
|
||||
with salt.utils.fopen(tgt, 'r') as cheese:
|
||||
data = cheese.read()
|
||||
self.assertIn('Gromit', data)
|
||||
self.assertIn('Comte', data)
|
||||
try:
|
||||
self.run_function('cp.get_file', ['salt://cheese', tgt])
|
||||
with salt.utils.fopen(tgt, 'r') as cheese:
|
||||
data = cheese.read()
|
||||
self.assertIn('Gromit', data)
|
||||
self.assertNotIn('Comte', data)
|
||||
finally:
|
||||
os.unlink(tgt)
|
||||
|
||||
def test_get_file_from_env_in_url(self):
|
||||
tgt = os.path.join(integration.TMP, 'cheese')
|
||||
try:
|
||||
self.run_function('cp.get_file', ['salt://cheese?env=prod', tgt])
|
||||
with salt.utils.fopen(tgt, 'r') as cheese:
|
||||
data = cheese.read()
|
||||
self.assertIn('Gromit', data)
|
||||
self.assertIn('Comte', data)
|
||||
finally:
|
||||
os.unlink(tgt)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -24,9 +24,10 @@ class StateModuleTest(integration.ModuleCase,
|
|||
state.show_highstate
|
||||
'''
|
||||
high = self.run_function('state.show_highstate')
|
||||
destpath = os.path.join(integration.SYS_TMP_DIR, 'testfile')
|
||||
self.assertTrue(isinstance(high, dict))
|
||||
self.assertTrue('/testfile' in high)
|
||||
self.assertEqual(high['/testfile']['__env__'], 'base')
|
||||
self.assertTrue(destpath in high)
|
||||
self.assertEqual(high[destpath]['__env__'], 'base')
|
||||
|
||||
def test_show_lowstate(self):
|
||||
'''
|
||||
|
@ -362,6 +363,20 @@ fi
|
|||
'The state "C" in sls syntax.badlist2 is not formed as a list'
|
||||
])
|
||||
|
||||
def test_get_file_from_env_in_top_match(self):
|
||||
tgt = os.path.join(integration.SYS_TMP_DIR, 'prod-cheese-file')
|
||||
try:
|
||||
ret = self.run_function(
|
||||
'state.highstate', minion_tgt='sub_minion'
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
with salt.utils.fopen(tgt, 'r') as cheese:
|
||||
data = cheese.read()
|
||||
self.assertIn('Gromit', data)
|
||||
self.assertIn('Comte', data)
|
||||
finally:
|
||||
os.unlink(tgt)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
Loading…
Add table
Reference in a new issue