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
Is your feature request related to a problem? Please describe.
As a helm chart author
in order to assert input validation code that trigger rendering error (e.g. using the required function
I need hcunit to support assertions on rendering error output
Describe the solution you'd like
Given the following template
apiVersion: servicecatalog.k8s.io/v1beta1kind: ServiceInstancemetadata:
namespace: {{ required "A valid namespace is required" .Values.namespace }} # Mandatory since ServiceInstance is a namespaced resource
When helm unit runs with a value missing namespace,
then a render_error hash in the input such as the following is available for assertions to check:
template: "hcunit/templates/serviceinstance.yaml"message: "error calling required: A valid namespace is required"statement: "required \"A valid namespace is required\" .Values.namespace>"line: 5column: 16
Note: statement, line and column are "nice-to-have". Policies would really need to assert on template and message.
----------------
Test suite ./unit-tests/mandatory-namespace with user inputs: ./unit-tests/mandatory-namespace/user-inputs/empty-user-inputs.yml ./unit-tests/mandatory-namespace/user-inputs/mocked-lookup-values.yml
Checking expected rendering failure in ./unit-tests/mandatory-namespace/policy/service_instance_should_fail_to_render.rego
error while rendering: render error in "hcunit/templates/serviceinstance.yaml": template: hcunit/templates/serviceinstance.yaml:5:16: executing "hcunit/templates/serviceinstance.yaml" at <required "A valid namespace is required" .Values.namespace>: error calling required: A valid namespace is required
Error: plugin "unit" exited with error
helm.go:81: [debug] plugin "unit" exited with error
Ok rendering was rejected as expected
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
As a helm chart author
Describe the solution you'd like
Given the following template
When helm unit runs with a value missing namespace,
then a
render_error
hash in the input such as the following is available for assertions to check:Note: statement, line and column are "nice-to-have". Policies would really need to assert on template and message.
Describe alternatives you've considered
Ignore rendering errors in tests, see for instance test launcher in sample project and associated output below
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: