mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
file.managed: Add test to ensure binary contents work
This commit is contained in:
parent
7b7dc94610
commit
8e214c9fa9
1 changed files with 19 additions and 0 deletions
|
@ -57,6 +57,8 @@ from salt.ext.six.moves import range # pylint: disable=import-error,redefined-b
|
|||
|
||||
IS_WINDOWS = salt.utils.platform.is_windows()
|
||||
|
||||
BINARY_FILE = b'GIF89a\x01\x00\x01\x00\x80\x00\x00\x05\x04\x04\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;'
|
||||
|
||||
STATE_DIR = os.path.join(FILES, 'file', 'base')
|
||||
if IS_WINDOWS:
|
||||
FILEPILLAR = 'C:\\Windows\\Temp\\filepillar-python'
|
||||
|
@ -2503,6 +2505,23 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
ret = self.run_function('state.sls', mods=state_file)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
def test_binary_contents(self):
|
||||
'''
|
||||
This tests to ensure that binary contents do not cause a traceback.
|
||||
'''
|
||||
name = os.path.join(TMP, '1px.gif')
|
||||
try:
|
||||
ret = self.run_state(
|
||||
'file.managed',
|
||||
name=name,
|
||||
contents=BINARY_FILE)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
finally:
|
||||
try:
|
||||
os.remove(name)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
class BlockreplaceTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
marker_start = '# start'
|
||||
|
|
Loading…
Add table
Reference in a new issue