Error¶
The error
operation lets you define a set of expected errors for a test step. If any of these errors occur during the test, they are treated as expected outcomes. However, if an error that's not on this list occurs, it will be treated as a test failure.
Info
Errors in Chainsaw are based on assertion trees.
Assertion trees is a solution to declaratively represent complex conditions like partial array comparisons or complex operations against an incoming data structure.
Assertion trees are compatible with standard assertions that exist in tools like KUTTL but can do a lot more. Please see the assertion trees documentation in kyverno-json for details.
Reference documentation
The full structure of the Error
is documented here.
Usage in Test
¶
Below is an example of using error
in a Test
resource.
Example
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: example
spec:
steps:
- try:
# ...
- error:
file: ../resources/configmap-error.yaml
# ...
Usage in TestStep
¶
Below is an example of using error
in a TestStep
resource.
Example
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: example
spec:
try:
# ...
- error:
file: ../resources/configmap-error.yaml
# ...