salt.states.test

Test States

Provide test case states that enable easy testing of things to do with
state calls, e.g. running, calling, logging, output filtering etc.
always-passes-with-any-kwarg:
  test.nop:
    - name: foo
    - something: else
    - foo: bar

always-passes:
  test.succeed_without_changes:
    - name: foo

always-fails:
  test.fail_without_changes:
    - name: foo

always-changes-and-succeeds:
  test.succeed_with_changes:
    - name: foo

always-changes-and-fails:
  test.fail_with_changes:
    - name: foo

my-custom-combo:
  test.configurable_test_state:
    - name: foo
    - changes: True
    - result: False
    - comment: bar.baz

is-pillar-foo-present-and-bar-is-int:
  test.check_pillar:
    - present:
        - foo
    - integer:
        - bar
salt.states.test.check_pillar(name, present=None, boolean=None, integer=None, string=None, listing=None, dictionary=None, verbose=False)

Checks the presence and, optionally, the type of given keys in Pillar. Supported kwargs for types are: - boolean (bool) - integer (int) - string (str) - listing (list) - dictionary (dict)

Checking for None type pillars is not implemented yet.

is-pillar-foo-present-and-bar-is-int:
  test.check_pillar:
    - present:
        - foo
    - integer:
        - bar
salt.states.test.configurable_test_state(name, changes=True, result=True, comment='')

A configurable test state which determines its output based on the inputs.

New in version 2014.7.0.

name:
A unique string.
changes:
Do we return anything in the changes field? Accepts True, False, and 'Random' Default is True
result:
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 ''
salt.states.test.fail_with_changes(name)

Returns failure and changes is not empty.

New in version 2014.7.0.

name:
A unique string.
salt.states.test.fail_without_changes(name)

Returns failure.

New in version 2014.7.0.

name:
A unique string.
salt.states.test.mod_watch(name, sfun=None, **kwargs)

' Call this function via a watch statement

New in version 2014.7.0.

Any parameters in the state return dictionary can be customized by adding the keywords result, comment, and changes.

this_state_will_return_changes:
  test.succeed_with_changes

this_state_will_NOT_return_changes:
  test.succeed_without_changes

this_state_is_watching_another_state:
  test.succeed_without_changes:
    - comment: 'This is a custom comment'
    - watch:
      - test: this_state_will_return_changes
      - test: this_state_will_NOT_return_changes

this_state_is_also_watching_another_state:
  test.succeed_without_changes:
    - watch:
      - test: this_state_will_NOT_return_changes
salt.states.test.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

New in version 2015.8.1.

salt.states.test.show_notification(name, text=None, **kwargs)

Simple notification using text argument.

New in version 2015.8.0.

name
A unique string.
text
Text to return in the comment.
salt.states.test.succeed_with_changes(name)

Returns successful and changes is not empty

New in version 2014.7.0.

name:
A unique string.
salt.states.test.succeed_without_changes(name)

Returns successful.

New in version 2014.7.0.

name
A unique string.