states.test.configurable_test_state test mode

Make `configurable_test_state` configurable even in test mode and return
the correct result in test mode as per
https://docs.saltstack.com/en/latest/ref/states/writing.html#return-data.
This commit is contained in:
Justin Findlay 2016-06-02 14:51:33 -06:00
parent 8a566ff4b9
commit f06ff1af1f

View file

@ -189,6 +189,8 @@ def configurable_test_state(name, changes=True, result=True, comment=''):
Do we return successfully or not?
Accepts True, False, and 'Random'
Default is True
If test is True and changes is True, this will be None. If test is
True and and changes is False, this will be True.
comment:
String to fill the comment field with.
Default is ''
@ -242,8 +244,8 @@ def configurable_test_state(name, changes=True, result=True, comment=''):
'\'Random\'')
if __opts__['test']:
ret['result'] = None
ret['comment'] = 'This is a test'
ret['result'] = True if changes is False else None
ret['comment'] = 'This is a test' if not comment else comment
return ret