MCPcopy
hub / github.com/helm/helm / TestNestedHelpersProducesMultilineStacktrace

Function TestNestedHelpersProducesMultilineStacktrace

pkg/engine/engine_test.go:1325–1362  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1323}
1324
1325func TestNestedHelpersProducesMultilineStacktrace(t *testing.T) {
1326 modTime := time.Now()
1327 c := &chart.Chart{
1328 Metadata: &chart.Metadata{Name: "NestedHelperFunctions"},
1329 Templates: []*common.File{
1330 {Name: "templates/svc.yaml", ModTime: modTime, Data: []byte(
1331 `name: {{ include "nested_helper.name" . }}`,
1332 )},
1333 {Name: "templates/_helpers_1.tpl", ModTime: modTime, Data: []byte(
1334 `{{- define "nested_helper.name" -}}{{- include "common.names.get_name" . -}}{{- end -}}`,
1335 )},
1336 {Name: "charts/common/templates/_helpers_2.tpl", ModTime: modTime, Data: []byte(
1337 `{{- define "common.names.get_name" -}}{{- .Values.nonexistant.key | trunc 63 | trimSuffix "-" -}}{{- end -}}`,
1338 )},
1339 },
1340 }
1341
1342 expectedErrorMessage := `NestedHelperFunctions/templates/svc.yaml:1:9
1343 executing "NestedHelperFunctions/templates/svc.yaml" at <include "nested_helper.name" .>:
1344 error calling include:
1345NestedHelperFunctions/templates/_helpers_1.tpl:1:39
1346 executing "nested_helper.name" at <include "common.names.get_name" .>:
1347 error calling include:
1348NestedHelperFunctions/charts/common/templates/_helpers_2.tpl:1:49
1349 executing "common.names.get_name" at <.Values.nonexistant.key>:
1350 nil pointer evaluating interface {}.key`
1351
1352 v := common.Values{}
1353
1354 val, _ := util.CoalesceValues(c, v)
1355 vals := map[string]any{
1356 "Values": val.AsMap(),
1357 }
1358 _, err := Render(c, vals)
1359
1360 assert.NotNil(t, err)
1361 assert.Equal(t, expectedErrorMessage, err.Error())
1362}
1363
1364func TestMultilineNoTemplateAssociatedError(t *testing.T) {
1365 modTime := time.Now()

Callers

nothing calls this directly

Calls 5

CoalesceValuesFunction · 0.92
RenderFunction · 0.85
NowMethod · 0.80
AsMapMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…