mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #27208 from basepi/nop.state.25423
[2015.5] Add test.nop state
This commit is contained in:
commit
f5a322e3f2
1 changed files with 17 additions and 3 deletions
|
@ -8,6 +8,12 @@ Provide test case states that enable easy testing of things to do with
|
|||
|
||||
.. code-block:: yaml
|
||||
|
||||
always-passes-with-any-kwarg:
|
||||
test.nop:
|
||||
- name: foo
|
||||
- something: else
|
||||
- foo: bar
|
||||
|
||||
always-passes:
|
||||
test.succeed_without_changes:
|
||||
- name: foo
|
||||
|
@ -43,6 +49,17 @@ from salt.exceptions import SaltInvocationError
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def nop(name, **kwargs):
|
||||
'''
|
||||
A no-op state that does nothing. Useful in conjunction with the `use`
|
||||
requisite, or in templates which could otherwise be empty due to jinja
|
||||
rendering
|
||||
|
||||
.. versionadded:: 2015.5.6
|
||||
'''
|
||||
return succeed_without_changes(name)
|
||||
|
||||
|
||||
def succeed_without_changes(name):
|
||||
'''
|
||||
Returns successful.
|
||||
|
@ -58,9 +75,6 @@ def succeed_without_changes(name):
|
|||
'result': True,
|
||||
'comment': 'Success!'
|
||||
}
|
||||
if __opts__['test']:
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'If we weren\'t testing, this would be a success!'
|
||||
return ret
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue