MCPcopy Create free account
hub / github.com/helm/helm / TestRender

Function TestRender

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

Source from the content-addressed store, hash-verified

92}
93
94func TestRender(t *testing.T) {
95 modTime := time.Now()
96 c := &chart.Chart{
97 Metadata: &chart.Metadata{
98 Name: "moby",
99 Version: "1.2.3",
100 },
101 Templates: []*common.File{
102 {Name: "templates/test1", ModTime: modTime, Data: []byte("{{.Values.outer | title }} {{.Values.inner | title}}")},
103 {Name: "templates/test2", ModTime: modTime, Data: []byte("{{.Values.global.callme | lower }}")},
104 {Name: "templates/test3", ModTime: modTime, Data: []byte("{{.noValue}}")},
105 {Name: "templates/test4", ModTime: modTime, Data: []byte("{{toJson .Values}}")},
106 {Name: "templates/test5", ModTime: modTime, Data: []byte("{{getHostByName \"helm.sh\"}}")},
107 },
108 Values: map[string]any{"outer": "DEFAULT", "inner": "DEFAULT"},
109 }
110
111 vals := map[string]any{
112 "Values": map[string]any{
113 "outer": "spouter",
114 "inner": "inn",
115 "global": map[string]any{
116 "callme": "Ishmael",
117 },
118 },
119 }
120
121 v, err := util.CoalesceValues(c, vals)
122 if err != nil {
123 t.Fatalf("Failed to coalesce values: %s", err)
124 }
125 out, err := Render(c, v)
126 if err != nil {
127 t.Errorf("Failed to render templates: %s", err)
128 }
129
130 expect := map[string]string{
131 "moby/templates/test1": "Spouter Inn",
132 "moby/templates/test2": "ishmael",
133 "moby/templates/test3": "",
134 "moby/templates/test4": `{"global":{"callme":"Ishmael"},"inner":"inn","outer":"spouter"}`,
135 "moby/templates/test5": "",
136 }
137
138 for name, data := range expect {
139 if out[name] != data {
140 t.Errorf("Expected %q, got %q", data, out[name])
141 }
142 }
143}
144
145func TestRenderRefsOrdering(t *testing.T) {
146 modTime := time.Now()

Callers

nothing calls this directly

Calls 4

CoalesceValuesFunction · 0.92
RenderFunction · 0.85
NowMethod · 0.80
FatalfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…