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

[question] Testing NamedTemplates in my chart #206

Open
grixxie opened this issue Apr 6, 2023 · 1 comment
Open

[question] Testing NamedTemplates in my chart #206

grixxie opened this issue Apr 6, 2023 · 1 comment

Comments

@grixxie
Copy link

grixxie commented Apr 6, 2023

Hey! First of all I just want to say I'm really impressed and enjoying this plugin :)

I'm fairly new to Helm in general. I've created a namedTemplate which is used in another yaml file in my chart using the include keyword.

I want to test the namedTemplate in isolation - is this possible?
I understand that a namedTemplate itself does not generate any output, and am also aware I could test this via the calling yaml; I'm mainly curious whether testing my namedTemplate by itself is possible.

A simple example below:

# NamedTemplate
{{- define "testNamedTemplate" -}}
key: {{ .Values.testValue }}
{{- end -}}
# my test
values: []
templates: []
tests:
  - it:
    template: 'testNamedTemplate.yaml'
    set:
      testValue: 'abc'
    asserts:
      - equal:
          path: key
          value: 'abc'

the above test will give me the error "asserts[0] equal fail".

My "fix" for this right now is to create a file in my chart called testNamedTemplate.include.yaml which is only used for tests, which looks like this:

# testNamedTemplate.include.yaml
{{- include "testNamedTemplate" . -}}

Hopefully this makes sense and isn't too dumb of a question :)

@rquinio
Copy link

rquinio commented Apr 10, 2023

@grixxie I don't think this is possible, as helm-unitest is basically calling "helm template" programatically,

For info the active repo is now at https://github.com/helm-unittest/helm-unittest

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

2 participants