package handlers import ( "html/template" "path/filepath" "testing" ) // New() only logs a warning when template parsing fails, so a malformed template // -- an unknown function, an unclosed action, a typo'd field pipeline -- ships // silently and only shows up as a broken page at runtime. This parses the real // template set with the real func map so that failure is a build-time failure // instead. func TestTemplates_AllParse(t *testing.T) { dir := filepath.Join("..", "..", "web", "templates") tmpl, err := template.New("").Funcs(templateFuncMap()).ParseGlob(filepath.Join(dir, "*.html")) if err != nil { t.Fatalf("parsing top-level templates: %v", err) } if _, err := tmpl.ParseGlob(filepath.Join(dir, "partials", "*.html")); err != nil { t.Fatalf("parsing partials: %v", err) } }