mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Add unit test for file.line on an empty content while not deleting anything
This commit is contained in:
parent
b5a80231bd
commit
f0f08a10e8
@ -872,6 +872,18 @@ class FileModuleTestCase(TestCase, LoaderModuleMockMixin):
|
||||
assert err_msg in str(cmd_err)
|
||||
|
||||
@skipIf(pytest is None, 'PyTest required for this test')
|
||||
@patch('os.path.realpath', MagicMock())
|
||||
@patch('os.path.isfile', MagicMock(return_value=True))
|
||||
def test_line_no_content(self):
|
||||
'''
|
||||
Test for file.line for an empty content when not deleting anything.
|
||||
:return:
|
||||
'''
|
||||
for mode in ['insert', 'ensure', 'replace']:
|
||||
with pytest.raises(CommandExecutionError) as cmd_err:
|
||||
filemod.line('foo', mode=mode)
|
||||
assert 'Content can only be empty if mode is "delete"' in str(cmd_err)
|
||||
|
||||
|
||||
class FileBasicsTestCase(TestCase, LoaderModuleMockMixin):
|
||||
def setup_loader_modules(self):
|
||||
|
Loading…
Reference in New Issue
Block a user