Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back-port #49299 to 2018.3.3 #49444

Merged
merged 3 commits into from Aug 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 27 additions & 14 deletions tests/integration/states/test_file.py
Expand Up @@ -776,7 +776,6 @@ def test_directory_symlink_dry_run(self):
ret = self.run_state(
'file.directory', test=True, name=sym_dir,
follow_symlinks=True, mode=700)

self.assertSaltTrueReturn(ret)
finally:
if os.path.isdir(tmp_dir):
Expand Down Expand Up @@ -2097,7 +2096,7 @@ def test_issue_8343_accumulated_require_in(self, base_dir):
'#-- end salt managed zoneend --',
'']

self.assertEqual(expected, contents)
self.assertEqual([line.encode('utf-8') for line in expected], contents)

@with_tempdir()
def test_issue_11003_immutable_lazy_proxy_sum(self, base_dir):
Expand Down Expand Up @@ -2189,6 +2188,10 @@ def test_issue_8947_utf8_sls(self, base_dir):
{korean_3}
- replace: True
- show_diff: True
'''.format(**locals()))

if not salt.utils.platform.is_windows():
template += textwrap.dedent('''\
some-utf8-file-content-test:
cmd.run:
- name: 'cat "{test_file}"'
Expand Down Expand Up @@ -2239,18 +2242,28 @@ def test_issue_8947_utf8_sls(self, base_dir):
ret['some-utf8-file-create2']['changes'],
{'diff': diff}
)

# Confirm that the file has the expected contents as specified in
# the prior state.
self.assertEqual(
ret['some-utf8-file-content-test']['comment'],
'Command "cat "{0}"" run'.format(test_file_encoded)
)
self.assertEqual(
ret['some-utf8-file-content-test']['changes']['stdout'],
'\n'.join((korean_2, korean_1, korean_3))
)

if salt.utils.platform.is_windows():
import subprocess
import win32api
p = subprocess.Popen(salt.utils.to_str('type {}'.format(win32api.GetShortPathName(test_file))),
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.poll()
out = p.stdout.read()
self.assertEqual(
out.decode('utf-8'),
os.linesep.join((korean_2, korean_1, korean_3)) + os.linesep
)
else:
self.assertEqual(
ret['some-utf8-file-content-test']['comment'],
'Command "cat "{0}"" run'.format(
test_file_encoded
)
)
self.assertEqual(
ret['some-utf8-file-content-test']['changes']['stdout'],
'\n'.join((korean_2, korean_1, korean_3))
)
finally:
try:
os.remove(template_path)
Expand Down