Skip to content

Commit

Permalink
Changed returned result when using test=true for mongodb_user.present…
Browse files Browse the repository at this point in the history
… to avoid false positives.
  • Loading branch information
dbuenor committed Jul 24, 2019
1 parent c3950a2 commit 889cc14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions salt/states/mongodb_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/states/test_mongodb_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}):
Expand Down

0 comments on commit 889cc14

Please sign in to comment.