Merge pull request #48004 from terminalmage/salt-jenkins-1008

Update tests to reflect changes in #47580
This commit is contained in:
Nicole Thomas 2018-06-06 15:02:45 -04:00 committed by GitHub
commit 2f8ea4a59d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 17 deletions

View File

@ -1376,6 +1376,7 @@ def symlink(
os.path.dirname(name)
)
)
if __salt__['file.is_link'](name):
# The link exists, verify that it matches the target
if os.path.normpath(__salt__['file.readlink'](name)) != os.path.normpath(target):

View File

@ -252,15 +252,24 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
with patch.object(os.path, 'isdir', mock_t):
with patch.object(os.path, 'exists', mock_f):
with patch.object(os.path, 'lexists', mock_t):
comt = ('File exists where the backup target SALT'
' should go')
comt = (
'Symlink & backup dest exists and Force not '
'set. {0} -> {1} - backup: {2}'.format(
name,
target,
os.path.join(test_dir, 'SALT')
)
)
ret.update({'comment': comt,
'result': False,
'pchanges': {'new': name}})
self.assertDictEqual(filestate.symlink
(name, target, user=user,
group=group, backupname='SALT'),
ret)
self.assertDictEqual(
filestate.symlink(
name, target, user=user,
group=group, backupname='SALT'
),
ret
)
with patch.dict(filestate.__salt__, {'config.manage_mode': mock_t,
'file.user_to_uid': mock_uid,
@ -270,17 +279,19 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
'user.info': mock_empty,
'user.current': mock_user}):
with patch.dict(filestate.__opts__, {'test': False}):
with patch.object(os.path, 'isabs', mock_t):
with patch.object(os.path, 'isabs', mock_f):
comt = ('Backupname must be an absolute path '
'or a file name: {0}').format('tmp/SALT')
ret.update({'comment': comt,
'result': False,
'pchanges': {'new': name}})
self.assertDictEqual(filestate.symlink
(name, target, user=user,
group=group, backupname='tmp/SALT'),
ret)
with patch.object(os.path, 'isfile', mock_t):
comt = ('Backupname must be an absolute path '
'or a file name: {0}').format('tmp/SALT')
ret.update({'comment': comt,
'result': False,
'pchanges': {'new': name}})
self.assertDictEqual(
filestate.symlink(
name, target, user=user,
group=group, backupname='tmp/SALT'
),
ret
)
with patch.dict(filestate.__salt__, {'config.manage_mode': mock_t,
'file.user_to_uid': mock_uid,