mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add tests for issue 51309
This commit is contained in:
parent
f1e29c82a8
commit
e3d3c5a8e2
1 changed files with 26 additions and 0 deletions
|
@ -9,11 +9,14 @@
|
|||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, unicode_literals, print_function
|
||||
import os
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.unit import TestCase
|
||||
from tests.support.helpers import generate_random_name
|
||||
|
||||
# Import salt libs
|
||||
import salt.modules.cmdmod as cmdmod
|
||||
from salt.utils.filebuffer import BufferedReader, InvalidFileMode
|
||||
|
||||
|
||||
|
@ -30,3 +33,26 @@ class TestFileBuffer(TestCase):
|
|||
|
||||
with self.assertRaises(InvalidFileMode):
|
||||
BufferedReader('/tmp/foo', mode='wb')
|
||||
|
||||
def test_issue_51309(self):
|
||||
'''
|
||||
https://github.com/saltstack/salt/issues/51309
|
||||
'''
|
||||
temp_name = os.path.join(os.environ.get('TEMP'),
|
||||
generate_random_name(prefix='salt-test-'))
|
||||
cmd = 'tzutil /l > {0}'.format(temp_name)
|
||||
cmdmod.run(cmd=cmd, python_shell=True)
|
||||
|
||||
def find_value(text):
|
||||
stripped_text = text.strip()
|
||||
try:
|
||||
with BufferedReader(temp_name) as breader:
|
||||
for chunk in breader:
|
||||
if stripped_text in chunk:
|
||||
return True
|
||||
return False
|
||||
except (IOError, OSError):
|
||||
return False
|
||||
|
||||
self.assertTrue(find_value('(UTC) Coordinated Universal Time'))
|
||||
os.remove(temp_name)
|
||||
|
|
Loading…
Add table
Reference in a new issue