helm-unittest icon indicating copy to clipboard operation
helm-unittest copied to clipboard

How can you view the the rendered template, when a test fails

Open fieldju opened this issue 3 years ago • 2 comments

:wave: hello, new to using this library.

I have a test

suite: rna tests
tempaltes:
  - deployment.yaml
tests:
  - it: adds env vars to the rna pod
    values:
      - values/env-var-values.yaml
    asserts:
      - equal:
          path: spec.template.spec.containers[0].env[0].name
          value: FOO
      - equal:
          path: spec.template.spec.containers[0].env[0].value
          value: bar

Its failing

❯ helm unittest --helm3 .

### Chart [ remote-network-agent ] .

 FAIL  rna tests        tests/deployment_test.yaml
        - adds env vars to the rna pod

                - asserts[0] `equal` fail

                - asserts[1] `equal` fail


Charts:      1 failed, 0 passed, 1 total
Test Suites: 1 failed, 0 passed, 1 total
Tests:       1 failed, 0 passed, 1 total
Snapshot:    0 passed, 0 total
Time:        1.647489ms

Error: plugin "unittest" exited with error

I'd like to see what was rendered when a tests fails or just in general to help write the tests.

Is there a way to see the rendered templates that I am missing?

fieldju avatar Jan 20 '22 21:01 fieldju

I had a typo in tempaltes -> templates when I fixed that things started working, but I still want to know if there is a way to view the rendered templates for a test.

fieldju avatar Jan 20 '22 21:01 fieldju

I was only able via helm template:

helm template releaseName chartName --values some.yaml --debug

wentwog avatar Oct 07 '22 16:10 wentwog