Skip to content

print $.Template.BasePath "/configmap.yaml" fails in unittests #162

Closed

Description

@venc0r

When a Template.BasePath is used the unittest fails. The solution provided in #53 does not help me.

❯ helm unittest .

### Chart [ unittest-tests ] .

 FAIL  test deployment  tests/deployment_test.yaml
        - should be a deployment
                Error: template: unittest-tests/templates/deployment.yaml:13:28: executing "unittest-tests/templates/deployment.yaml" at <include (print $.Template.BasePath "/configmap.yaml") .>: error calling include: template: no template "unittest-tests/templates/configmap.yaml" associated with template "gotpl"


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

Error: plugin "unittest" exited with error

Initially I have faced this problem in a chart where I include the kube-prometheus-stack as dependency. I've built a basic chart to reproduce the error in its simplest way:
https://github.com/venc0r/helm-unittest-test

The problem occurs since v0.3.3

Activity

  1. venc0r commented on May 23, 2023

    @venc0r
    Author

    I was only specifing the template at root level and not at test level. When I add all required files at root level and the specific file at test level it works again.
    before:

    ---
    suite: test deployment
    templates:
      - charts/kube-prometheus-stack/charts/grafana/templates/deployment.yaml
    tests:
      - it: should be a deployment
        asserts:
          - isKind:
              of: Deployment
    

    after:

    ---
    suite: test deployment
    templates:
      - charts/kube-prometheus-stack/charts/grafana/templates/configmap.yaml
      - charts/kube-prometheus-stack/charts/grafana/templates/deployment.yaml
      - charts/kube-prometheus-stack/charts/grafana/templates/secret.yaml
      - charts/kube-prometheus-stack/charts/grafana/templates/dashboards-json-configmap.yaml
      - charts/kube-prometheus-stack/charts/grafana/templates/configmap-dashboard-provider.yaml
    tests:
      - it: should be a deployment
        set:
          kube-prometheus-stack.grafana.envRenderSecret: true
        template: charts/kube-prometheus-stack/charts/grafana/templates/deployment.yaml
        asserts:
          - isKind:
              of: Deployment
    
  2. self-assigned this
    on Jun 12, 2023
  3. quintush commented on Aug 21, 2023

    @quintush
    Contributor

    Closed as answer is already given by the author.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions