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

Ordering of rendered documents #166

Open
erik-carlson opened this issue May 6, 2022 · 2 comments
Open

Ordering of rendered documents #166

erik-carlson opened this issue May 6, 2022 · 2 comments

Comments

@erik-carlson
Copy link

I just started using this tool and I'm trying to write tests for a chart that uses named templates and finding that the order of documents that unittest renders is different from that generated by helm template.

For instance if I have a chart with a named template for an Ingress resource and another for a ConfigMap resource, then I have one template file that includes the ingress first and then the configmap, helm template will actually show the ConfigMap first and then the Ingress. Then if I write a test to validate that the first document is a ConfigMap it fails and says that it is an Ingress. Furthermore, if I switch the order of the includes the output of helm template doesn't change, but it does change the result of the test.

I assume that there is some kind of sorting going on in helm template that isn't happening with unittest. Barring changing the way that unittest works (I assume that this change would be non-trivial), is there a way either with unittest or helm that you know of for at least seeing the order of documents as unittest sees them? As it is finding the right index is trial and error.

I'm using helm 3.8.1 and unittest 0.2.8.

@kazysgurskas
Copy link

Ran into this recently also.
Must have several templates defined in the templates array, due to one include'ing the other. Then the assertion returns this:

				can't get ["template"] from a non map type:
				null

Specifying documentIndex: 1 resolves the issue.

@quintush
Copy link
Owner

Hello @erik-carlson,

The rendering of the 0.2.8 helm unittest is done with the 3.7.1 library, so the behaviour can indeed be different.
I will try to update the libraries more regular, to align with the latest version.

Greetings,
@quintush

b.t.w. the 0.2.9 version will use the current latest helm (3.10.0) library.

d3adb5 pushed a commit to d3adb5/helm-unittest-tests that referenced this issue Apr 30, 2024
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

3 participants