| 429 | } |
| 430 | |
| 431 | func TestParallelRenderInternals(t *testing.T) { |
| 432 | // Make sure that we can use one Engine to run parallel template renders. |
| 433 | e := new(Engine) |
| 434 | var wg sync.WaitGroup |
| 435 | for i := range 20 { |
| 436 | wg.Add(1) |
| 437 | go func(i int) { |
| 438 | tt := fmt.Sprintf("expect-%d", i) |
| 439 | tpls := map[string]renderable{ |
| 440 | "t": { |
| 441 | tpl: `{{.val}}`, |
| 442 | vals: map[string]any{"val": tt}, |
| 443 | }, |
| 444 | } |
| 445 | out, err := e.render(tpls) |
| 446 | if err != nil { |
| 447 | t.Errorf("Failed to render %s: %s", tt, err) |
| 448 | } |
| 449 | if out["t"] != tt { |
| 450 | t.Errorf("Expected %q, got %q", tt, out["t"]) |
| 451 | } |
| 452 | wg.Done() |
| 453 | }(i) |
| 454 | } |
| 455 | wg.Wait() |
| 456 | } |
| 457 | |
| 458 | func TestParseErrors(t *testing.T) { |
| 459 | vals := common.Values{"Values": map[string]any{}} |