quintush / helm-unittest

BDD styled unit test framework for Kubernetes Helm charts as a Helm plugin.
MIT License
345 stars 69 forks source link

[bug] - failedTemplate assertion is not working as expected #180

Closed froy001 closed 1 year ago

froy001 commented 1 year ago

I have a failedTempate assertion:

    asserts:
      - failedTemplate:
          errorMessage: |
             global.application.commit and global.application.remoteOrigin must be given if rookout.enabled = true 

I get the following assertion failure:

        - asserts[0] `failedTemplate` fail
            Template:   charts-integration-test/charts/app-01/templates/deployment.yaml
            Template:   charts-integration-test/charts/app-02/templates/deployment.yaml
            DocumentIndex:  0
            Expected to equal:
                global.application.commit and global.application.remoteOrigin must be given if rookout.enabled = true
            Actual:
                global.application.commit and global.application.remoteOrigin must be given if rookout.enabled = true

As can be seen the expected and the actual values are exactly the same. This could be related to #174

rquinio1A commented 1 year ago

Could you check there's no extra \n at the end of the message ? cf discussion in https://github.com/quintush/helm-unittest/pull/155

quintush commented 1 year ago

Hello @froy001,

Due to formatting the expected value seems to be equal to the actual value. I have added an option --debug (-d) which should show the content without the formatting, showing the actual difference. https://github.com/quintush/helm-unittest/blob/master/FAQ.md#debugging, describes the usage.

As for the above issue. When using the multi-line string (|), the text will always end with a line-ending (\n), resulting in a mismatch. The actual error will result in a single line string.