From 889cc1404087c72d82841e562a87e064de94e664 Mon Sep 17 00:00:00 2001 From: David Bueno Date: Wed, 24 Jul 2019 14:02:08 +0200 Subject: [PATCH] Changed returned result when using test=true for mongodb_user.present to avoid false positives. --- salt/states/mongodb_user.py | 3 --- tests/unit/states/test_mongodb_user.py | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/salt/states/mongodb_user.py b/salt/states/mongodb_user.py index 7b5c53d5ad94..84cb9e129c22 100644 --- a/salt/states/mongodb_user.py +++ b/salt/states/mongodb_user.py @@ -106,9 +106,6 @@ def present(name, return ret if __opts__['test']: - ret['result'] = None - ret['comment'] = ('User {0} is already present and should be updated if neccesary.' - ).format(name) return ret # check each user occurrence diff --git a/tests/unit/states/test_mongodb_user.py b/tests/unit/states/test_mongodb_user.py index ade3f81e5b45..400e8d7f67dc 100644 --- a/tests/unit/states/test_mongodb_user.py +++ b/tests/unit/states/test_mongodb_user.py @@ -95,15 +95,15 @@ def test_present_existing_user(self): 'mongodb.user_create': mock_t, 'mongodb.user_find': mock }): - comt = ('User {0} is already present and should be updated if neccesary.' + comt = ('User {0} is already present' ).format(name) - ret.update({'comment': comt, 'result': None}) + ret.update({'comment': comt, 'result': True}) self.assertDictEqual(mongodb_user.present(name, passwd, database=db, roles=new_role), ret) with patch.dict(mongodb_user.__opts__, {'test': True}): - comt = ('User {0} is already present and should be updated if neccesary.' + comt = ('User {0} is already present' .format(name)) - ret.update({'comment': comt, 'result': None}) + ret.update({'comment': comt, 'result': True}) self.assertDictEqual(mongodb_user.present(name, passwd, database=db, roles=new_role), ret) with patch.dict(mongodb_user.__opts__, {'test': False}):