mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 00:25:22 +00:00
Merge pull request #54576 from garethgreenaway/2019_2_1_port_52933
[master] Porting #52933 to master
This commit is contained in:
commit
9edcfab3f3
@ -117,6 +117,10 @@ def validate(config):
|
||||
if 'files' not in _config:
|
||||
return False, 'Configuration for inotify beacon must include files.'
|
||||
else:
|
||||
if not isinstance(_config['files'], dict):
|
||||
return False, ('Configuration for inotify beacon invalid, '
|
||||
'files must be a dict.')
|
||||
|
||||
for path in _config.get('files'):
|
||||
|
||||
if not isinstance(_config['files'][path], dict):
|
||||
|
@ -39,10 +39,33 @@ class INotifyBeaconTestCase(TestCase, LoaderModuleMockMixin):
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmpdir, ignore_errors=True)
|
||||
|
||||
def test_non_list_config(self):
|
||||
config = {}
|
||||
|
||||
ret = inotify.validate(config)
|
||||
|
||||
self.assertEqual(ret, (False, 'Configuration for inotify beacon must'
|
||||
' be a list.'))
|
||||
|
||||
def test_empty_config(self):
|
||||
config = [{}]
|
||||
ret = inotify.beacon(config)
|
||||
self.assertEqual(ret, [])
|
||||
ret = inotify.validate(config)
|
||||
_expected = (False, 'Configuration for inotify beacon must include files.')
|
||||
self.assertEqual(ret, _expected)
|
||||
|
||||
def test_files_none_config(self):
|
||||
config = [{'files': None}]
|
||||
ret = inotify.validate(config)
|
||||
_expected = (False, 'Configuration for inotify beacon invalid, '
|
||||
'files must be a dict.')
|
||||
self.assertEqual(ret, _expected)
|
||||
|
||||
def test_files_list_config(self):
|
||||
config = [{'files': [{u'/importantfile': {u'mask': [u'modify']}}]}]
|
||||
ret = inotify.validate(config)
|
||||
_expected = (False, 'Configuration for inotify beacon invalid, '
|
||||
'files must be a dict.')
|
||||
self.assertEqual(ret, _expected)
|
||||
|
||||
def test_file_open(self):
|
||||
path = os.path.realpath(__file__)
|
||||
|
Loading…
Reference in New Issue
Block a user