mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Fix test_file_copy_make_dirs that was failing on Linux
I wasn't running sudo, but now it tells you that And verifies that the user is added and the state is run successfully before continuing with the test
This commit is contained in:
parent
8d0529d417
commit
81110e55ce
@ -362,11 +362,14 @@ class SaltLoggingClass(six.with_metaclass(LoggingMixInMeta, LOGGING_LOGGER_CLASS
|
||||
extra = None
|
||||
|
||||
# Let's try to make every logging message unicode
|
||||
salt_system_encoding = __salt_system_encoding__
|
||||
if salt_system_encoding == 'ascii':
|
||||
# Encoding detection most likely failed, let's use the utf-8
|
||||
# value which we defaulted before __salt_system_encoding__ was
|
||||
# implemented
|
||||
try:
|
||||
salt_system_encoding = __salt_system_encoding__
|
||||
if salt_system_encoding == 'ascii':
|
||||
# Encoding detection most likely failed, let's use the utf-8
|
||||
# value which we defaulted before __salt_system_encoding__ was
|
||||
# implemented
|
||||
salt_system_encoding = 'utf-8'
|
||||
except NameError:
|
||||
salt_system_encoding = 'utf-8'
|
||||
|
||||
if isinstance(msg, six.string_types) \
|
||||
|
@ -1764,7 +1764,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
with salt.utils.files.fopen(path_test, 'rb') as fp_:
|
||||
serialized_file = salt.utils.stringutils.to_unicode(fp_.read())
|
||||
|
||||
# The JSON serializer uses LF even on OSes where os.path.sep is CRLF.
|
||||
# The JSON serializer uses LF even on OSes where os.sep is CRLF.
|
||||
expected_file = '\n'.join([
|
||||
'{',
|
||||
' "a_list": [',
|
||||
@ -2609,15 +2609,17 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
|
||||
user = 'salt'
|
||||
mode = '0644'
|
||||
self.run_function('user.add', [user])
|
||||
ret = self.run_function('user.add', [user])
|
||||
self.assertTrue(ret, 'Failed to add user. Are you running as sudo?')
|
||||
ret = self.run_state('file.copy', name=dest, source=source, user=user,
|
||||
makedirs=True, mode=mode)
|
||||
makedirs=True, mode=mode)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
file_checks = [dest, os.path.join(TMP, 'dir1'), os.path.join(TMP, 'dir1', 'dir2')]
|
||||
for check in file_checks:
|
||||
user_check = self.run_function('file.get_user', [check])
|
||||
mode_check = self.run_function('file.get_mode', [check])
|
||||
assert user_check == user
|
||||
assert salt.utils.files.normalize_mode(mode_check) == mode
|
||||
self.assertEqual(user_check, user)
|
||||
self.assertEqual(salt.utils.files.normalize_mode(mode_check), mode)
|
||||
|
||||
def test_contents_pillar_with_pillar_list(self):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user