| 185 | } |
| 186 | |
| 187 | func TestRenderInternals(t *testing.T) { |
| 188 | // Test the internals of the rendering tool. |
| 189 | |
| 190 | vals := common.Values{"Name": "one", "Value": "two"} |
| 191 | tpls := map[string]renderable{ |
| 192 | "one": {tpl: `Hello {{title .Name}}`, vals: vals}, |
| 193 | "two": {tpl: `Goodbye {{upper .Value}}`, vals: vals}, |
| 194 | // Test whether a template can reliably reference another template |
| 195 | // without regard for ordering. |
| 196 | "three": {tpl: `{{template "two" dict "Value" "three"}}`, vals: vals}, |
| 197 | } |
| 198 | |
| 199 | out, err := new(Engine).render(tpls) |
| 200 | if err != nil { |
| 201 | t.Fatalf("Failed template rendering: %s", err) |
| 202 | } |
| 203 | |
| 204 | if len(out) != 3 { |
| 205 | t.Fatalf("Expected 3 templates, got %d", len(out)) |
| 206 | } |
| 207 | |
| 208 | if out["one"] != "Hello One" { |
| 209 | t.Errorf("Expected 'Hello One', got %q", out["one"]) |
| 210 | } |
| 211 | |
| 212 | if out["two"] != "Goodbye TWO" { |
| 213 | t.Errorf("Expected 'Goodbye TWO'. got %q", out["two"]) |
| 214 | } |
| 215 | |
| 216 | if out["three"] != "Goodbye THREE" { |
| 217 | t.Errorf("Expected 'Goodbye THREE'. got %q", out["two"]) |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | func TestRenderWithDNS(t *testing.T) { |
| 222 | c := &chart.Chart{ |