|
|
|
@ -49,7 +49,7 @@ func TestFuncMap(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test for Engine-specific template functions.
|
|
|
|
|
expect := []string{"include", "required", "toYaml", "fromYaml", "toToml", "toJson", "fromJson"}
|
|
|
|
|
expect := []string{"include", "required", "tpl", "toYaml", "fromYaml", "toToml", "toJson", "fromJson"}
|
|
|
|
|
for _, f := range expect {
|
|
|
|
|
if _, ok := fns[f]; !ok {
|
|
|
|
|
t.Errorf("Expected add-on function %q", f)
|
|
|
|
@ -445,4 +445,33 @@ func TestAlterFuncMap(t *testing.T) {
|
|
|
|
|
t.Errorf("Expected %q, got %q (%v)", expectNum, gotNum, outReq)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tplChart := &chart.Chart{
|
|
|
|
|
Metadata: &chart.Metadata{Name: "TplFunction"},
|
|
|
|
|
Templates: []*chart.Template{
|
|
|
|
|
{Name: "templates/base", Data: []byte(`Evaluate tpl {{tpl "Value: {{ .Values.value}}" .}}`)},
|
|
|
|
|
},
|
|
|
|
|
Values: &chart.Config{Raw: ``},
|
|
|
|
|
Dependencies: []*chart.Chart{},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tplValues := chartutil.Values{
|
|
|
|
|
"Values": chartutil.Values{
|
|
|
|
|
"value": "myvalue",
|
|
|
|
|
},
|
|
|
|
|
"Chart": tplChart.Metadata,
|
|
|
|
|
"Release": chartutil.Values{
|
|
|
|
|
"Name": "TestRelease",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outTpl, err := New().Render(tplChart, tplValues)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expectTplStr := "Evaluate tpl Value: myvalue"
|
|
|
|
|
if gotStrTpl := outTpl["TplFunction/templates/base"]; gotStrTpl != expectTplStr {
|
|
|
|
|
t.Errorf("Expected %q, got %q (%v)", expectTplStr, gotStrTpl, outTpl)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|