Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support assert error message with regex #217

Closed
fernandosci opened this issue Sep 18, 2023 · 1 comment
Closed

Support assert error message with regex #217

fernandosci opened this issue Sep 18, 2023 · 1 comment

Comments

@fernandosci
Copy link

This is a follow-up of #200

given the template

{{- tpl "{{ fail 'error message' }}" . }}

and test

suite: test tpl

templates:
  - test.yaml
tests:
  - it: tpl error message
    asserts:
      - failedTemplate:
          errorMessage: error message

it produces:

### Chart [ helm-chart ] helm-chart

 FAIL  test tpl helm-chart/tests/fail_test.yaml
        - tpl error message

                - asserts[0] `failedTemplate` fail
                        Template:       helm-chart/templates/test.yaml
                        DocumentIndex:  0
                        Expected to equal:
                                test
                        Actual:
                                error calling tpl: error during tpl function execution for "{{ fail 'error message' }}": parse error at (helm-chart/templates/test.yaml:1): 'error message'

in order to validate this message it would require defining the complete call stack including lines.

would it be possible to introduce an "errorMessageMatchRegex" for the failedTemplate assertion?

Something like this:

suite: test tpl

templates:
  - test.yaml
tests:
  - it: tpl error message
    asserts:
      - failedTemplate:
          errorMessageMatchRegex: error\smessage$
@fernandosci
Copy link
Author

closing as duplicate of #218 and #221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant