| 1290 | } |
| 1291 | |
| 1292 | func 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 | |
| 1325 | func TestNestedHelpersProducesMultilineStacktrace(t *testing.T) { |
| 1326 | modTime := time.Now() |