Make windows file remove return like others

This commit is contained in:
Daniel A. Wozniak 2018-09-11 08:37:46 -07:00
parent 5770b05612
commit bee29024f5
No known key found for this signature in database
GPG key ID: 166B9D2C06C82D61
2 changed files with 7 additions and 11 deletions

View file

@ -1066,13 +1066,14 @@ def remove(path, force=False):
path = os.path.expanduser(path)
if not os.path.isabs(path):
raise SaltInvocationError('File path must be absolute: {0}'.format(path))
# Does the file/folder exists
if not os.path.exists(path):
raise CommandExecutionError('Path not found: {0}'.format(path))
if not os.path.isabs(path):
raise SaltInvocationError('File path must be absolute.')
# Remove ReadOnly Attribute
if force:
# Get current file attributes

View file

@ -179,14 +179,9 @@ class FileModuleTest(ModuleCase):
def test_cannot_remove(self):
ret = self.run_function('file.remove', arg=['tty'])
if salt.utils.platform.is_windows():
self.assertEqual(
'ERROR: Path not found: tty', ret
)
else:
self.assertEqual(
'ERROR executing \'file.remove\': File path must be absolute: tty', ret
)
self.assertEqual(
'ERROR executing \'file.remove\': File path must be absolute: tty', ret
)
def test_source_list_for_single_file_returns_unchanged(self):
ret = self.run_function('file.source_list', ['salt://http/httpd.conf',