Merge pull request #44190 from prymitive/postgres_extension

Fix test=true checks so that state runs in test mode don't report cha…
This commit is contained in:
Mike Place 2017-10-31 11:53:06 -06:00 committed by GitHub
commit c46490c183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View File

@ -121,14 +121,15 @@ def present(name,
if flag in mtdata:
toupgrade = True
mode = 'upgrade'
if __opts__['test']:
ret['result'] = None
if mode:
ret['comment'] = 'Extension {0} is set to be {1}ed'.format(
name, mode).replace('eed', 'ed')
return ret
cret = None
if toinstall or toupgrade:
if __opts__['test']:
ret['result'] = None
if mode:
ret['comment'] = 'Extension {0} is set to be {1}ed'.format(
name, mode).replace('eed', 'ed')
return ret
cret = __salt__['postgres.create_extension'](
name=name,
if_not_exists=if_not_exists,

View File

@ -422,8 +422,8 @@ class PostgresExtensionTestCase(TestCase, LoaderModuleMockMixin):
ret = postgres_extension.present('foo')
self.assertEqual(
ret,
{'comment': "Extension foo is set to be created",
'changes': {}, 'name': 'foo', 'result': None}
{'comment': "Extension foo is already present",
'changes': {}, 'name': 'foo', 'result': True}
)
ret = postgres_extension.present('foo')

View File

@ -45,8 +45,8 @@ class PostgresExtensionTestCase(TestCase, LoaderModuleMockMixin):
with patch.dict(postgres_extension.__salt__,
{'postgres.create_metadata': mock}):
with patch.dict(postgres_extension.__opts__, {'test': True}):
comt = ('Extension {0} is set to be created'.format(name))
ret.update({'comment': comt, 'result': None})
comt = ('Extension {0} is already present'.format(name))
ret.update({'comment': comt, 'result': True})
self.assertDictEqual(postgres_extension.present(name), ret)
with patch.dict(postgres_extension.__opts__, {'test': False}):