blob: ffaf137b4c0c0e4c4684de9dd3cc5078992416c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
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)
}
}
|