MCPcopy
hub / github.com/helm/helm / TestFailErrors

Function TestFailErrors

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

Source from the content-addressed store, hash-verified

536}
537
538func TestFailErrors(t *testing.T) {
539 vals := common.Values{"Values": map[string]any{}}
540
541 failtpl := `All your base are belong to us{{ fail "This is an error" }}`
542 tplsFailed := map[string]renderable{
543 "failtpl": {tpl: failtpl, vals: vals},
544 }
545 _, err := new(Engine).render(tplsFailed)
546 if err == nil {
547 t.Fatalf("Expected failures while rendering: %s", err)
548 }
549 expected := `execution error at (failtpl:1:33): This is an error`
550 if err.Error() != expected {
551 t.Errorf("Expected '%s', got %q", expected, err.Error())
552 }
553
554 var e Engine
555 e.LintMode = true
556 out, err := e.render(tplsFailed)
557 if err != nil {
558 t.Fatal(err)
559 }
560
561 expectStr := "All your base are belong to us"
562 if gotStr := out["failtpl"]; gotStr != expectStr {
563 t.Errorf("Expected %q, got %q (%v)", expectStr, gotStr, out)
564 }
565}
566
567func TestAllTemplates(t *testing.T) {
568 modTime := time.Now()

Callers

nothing calls this directly

Calls 4

renderMethod · 0.95
FatalfMethod · 0.80
FatalMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…