zester
GuidesModules

Test Helpers

Salt-compatible test states for exercising requisites, failure handling, and reporting without touching the system. Like test.ping, they need no exec providers.

Source: pkg/state/modules/test_extra.go


test.nop

A no-op that always succeeds and reports no changes. Check reports the state as already satisfied, so Apply normally does not even run.

placeholder:
  test.nop: []
ParameterTypeRequiredDefaultDescription
(none)

test.fail_without_changes

Always fails, reporting no changes. Useful for testing onfail chains and failure propagation.

ParameterTypeRequiredDefaultDescription
commentstringNofailure without changesMessage included in the error and result details.
simulated-failure:
  test.fail_without_changes:
    - comment: "primary service unavailable"

fallback:
  cmd.run:
    - command: /usr/local/bin/failover.sh
    - onfail:
      - "test.fail_without_changes:simulated-failure"

test.succeed_with_changes

Always succeeds and reports Changed: true. Useful for testing watch and onchanges chains.

ParameterTypeRequiredDefaultDescription
commentstringNo""Optional message included in the result details.
simulated-change:
  test.succeed_with_changes: []

reactor:
  cmd.run:
    - command: echo "reacting to change"
    - onchanges:
      - "test.succeed_with_changes:simulated-change"

test.configurable_test_state

Result and change reporting fully driven by config. Check always forces Apply so the configuration controls the reported outcome.

ParameterTypeRequiredDefaultDescription
resultboolNotruefalse makes the state fail (error message from comment, or configured failure).
changesboolNotrueWhether the state reports Changed: true — honored on both success and failure.
commentstringNo""Message included in the result details / error.
scenario:
  test.configurable_test_state:
    - result: true
    - changes: false
    - comment: "healthy, nothing changed"

All states also accept the full set of requisite parameters and Salt-parity state attributes — see Dependencies & Requisites.

Revert Behavior

All test helpers are no-ops on Revert (Changed: false).


Divergences from Salt

  • Salt's test.show_notification and test.mod_watch behaviors are not implemented.
  • In Salt, test.configurable_test_state accepts result: Sometimes / changes: Random for randomized outcomes; Zester only accepts booleans (non-bool values fall back to the defaults).

On this page