mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #48582 from dwoz/test_prepend_fix
Finally fix prepend for real
This commit is contained in:
commit
10124034cb
1 changed files with 10 additions and 10 deletions
|
@ -62,11 +62,11 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
|||
}
|
||||
|
||||
def tearDown(self):
|
||||
remove_dir = '/etc'
|
||||
remove_dir = '/tmp/etc'
|
||||
if salt.utils.is_windows():
|
||||
remove_dir = 'c:\\etc'
|
||||
remove_dir = 'c:\\tmp\\etc'
|
||||
try:
|
||||
os.remove(remove_dir)
|
||||
salt.utils.rm_rf(remove_dir)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
@ -1183,10 +1183,10 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
Test to ensure that some text appears at the beginning of a file.
|
||||
'''
|
||||
assert not os.path.exists('c:\\etc')
|
||||
name = '/etc/motd'
|
||||
name = '/tmp/etc/motd'
|
||||
if salt.utils.is_windows():
|
||||
name = 'c:\\etc\\motd'
|
||||
name = 'c:\\tmp\\etc\\motd'
|
||||
assert not os.path.exists(os.path.split(name)[0])
|
||||
source = ['salt://motd/hr-messages.tmpl']
|
||||
sources = ['salt://motd/devops-messages.tmpl']
|
||||
text = ['Trust no one unless you have eaten much salt with him.']
|
||||
|
@ -1215,12 +1215,12 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
|||
'cp.get_template': mock_f,
|
||||
'file.search': mock_f,
|
||||
'file.prepend': mock_t}):
|
||||
comt = ('The following files will be changed:\n/etc:'
|
||||
comt = ('The following files will be changed:\n/tmp/etc:'
|
||||
' directory - new\n')
|
||||
pchanges = {'/etc': {'directory': 'new'}}
|
||||
pchanges = {'/tmp/etc': {'directory': 'new'}}
|
||||
if salt.utils.is_windows():
|
||||
comt = 'The directory "c:\\etc" will be changed'
|
||||
pchanges = {'c:\\etc': {'directory': 'new'}}
|
||||
comt = 'The directory "c:\\tmp\\etc" will be changed'
|
||||
pchanges = {'c:\\tmp\\etc': {'directory': 'new'}}
|
||||
ret.update({'comment': comt, 'name': name, 'pchanges': pchanges})
|
||||
self.assertDictEqual(filestate.prepend(name, makedirs=True),
|
||||
ret)
|
||||
|
|
Loading…
Add table
Reference in a new issue