MCPcopy
hub / github.com/helm/helm / TestRenderTplMissingKeyString

Function TestRenderTplMissingKeyString

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

Source from the content-addressed store, hash-verified

1290}
1291
1292func TestRenderTplMissingKeyString(t *testing.T) {
1293 // Rendering a missing key results in error
1294 c := &chart.Chart{
1295 Metadata: &chart.Metadata{Name: "TplMissingKeyStrict"},
1296 Templates: []*common.File{
1297 {Name: "templates/manifest", ModTime: time.Now(), Data: []byte(
1298 `missingValue: {{tpl "{{.Values.noSuchKey}}" .}}`,
1299 )},
1300 },
1301 }
1302 v := common.Values{
1303 "Values": common.Values{},
1304 "Chart": c.Metadata,
1305 "Release": common.Values{
1306 "Name": "TestRelease",
1307 },
1308 }
1309
1310 e := new(Engine)
1311 e.Strict = true
1312
1313 out, err := e.Render(c, v)
1314 if err == nil {
1315 t.Errorf("Expected error, got %v", out)
1316 return
1317 }
1318 errTxt := fmt.Sprint(err)
1319 if !strings.Contains(errTxt, "noSuchKey") {
1320 t.Errorf("Expected error to contain 'noSuchKey', got %s", errTxt)
1321 }
1322
1323}
1324
1325func TestNestedHelpersProducesMultilineStacktrace(t *testing.T) {
1326 modTime := time.Now()

Callers

nothing calls this directly

Calls 3

NowMethod · 0.80
RenderMethod · 0.80
ContainsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…