quintush / helm-unittest

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

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

Open fieldju opened 2 years ago

fieldju commented 2 years ago

: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 commented 2 years ago

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.

wentwog commented 2 years ago

I was only able via helm template:

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