Add unit test for _get_pillar_errors when external pillar has errors and internal is clean

This commit is contained in:
Bo Maryniuk 2017-11-21 13:50:04 +01:00
parent 3ce19356c2
commit 218a59e93b

View file

@ -991,3 +991,17 @@ class StateTestCase(TestCase, LoaderModuleMockMixin):
({}, None)]:
assert res == state._get_pillar_errors(kwargs=opts, pillar=ext_pillar)
def test_get_pillar_errors_EC(self):
'''
Test _get_pillar_errors function.
EC: External erroneous, Internal clean
:return:
'''
errors = ['failure', 'everywhere']
for int_pillar, ext_pillar in [({'foo': 'bar'}, {'fred': 'baz', '_errors': errors}),
({}, {'fred': 'baz', '_errors': ['failure', 'everywhere']})]:
with patch('salt.modules.state.__pillar__', int_pillar):
for opts, res in [({'force': True}, None),
({'force': False}, errors),
({}, errors)]:
assert res == state._get_pillar_errors(kwargs=opts, pillar=ext_pillar)