You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To test that every object has an app label or something like a support link, I would like to formulate a test like this:
suite: test app labeltemplates:
- templates/*.yamltests:
- it: object has app labelasserts:
- equal:
path: metadata.labels.appvalue: myapp
According to documentSelector this should default select "all" documents within every (*.yaml) template file.
Now the document structure already has some template surrounded by feature flags, so some files might render empty, and thus do not comprise documents.
templates/file-v1.yaml:
{{- if .Values.features.magic }}
# see file-v2.yaml
{{- else }}
---
kind: ...
{{- end }}
templates/file-v2.yaml:
{{- if .Values.features.magic }}
---
kind: ...
{{- end }}
I would expect that asserts on all documents in all templates would somehow accept empty templates, but the assert fails if not at least one document can be found per template. As I see certainly why asserts should raise if no document is fulfilling the assert, I would like to know if it is possible to test this similarly?
The text was updated successfully, but these errors were encountered:
The unittests are indeed very strict in validating "all" templates. So the validation will fail when an empty file is part of the assertions. This setup is by design.
The best way to validate all templates is by ensure "all" template do get generated, which can be done by setting the features.magic values as part of the test. The following namesOveride test shows a similar approach where the assertions are all validated against to mention list of templates, where the ingess.enabled value has been set to true, otherwise the ingress template would result in an empty file (failing the assertion).
To test that every object has an app label or something like a support link, I would like to formulate a test like this:
According to documentSelector this should default select "all" documents within every (*.yaml) template file.
Now the document structure already has some template surrounded by feature flags, so some files might render empty, and thus do not comprise documents.
templates/file-v1.yaml
:templates/file-v2.yaml
:I would expect that asserts on all documents in all templates would somehow accept empty templates, but the assert fails if not at least one document can be found per template. As I see certainly why asserts should raise if no document is fulfilling the assert, I would like to know if it is possible to test this similarly?
The text was updated successfully, but these errors were encountered: