summaryrefslogtreecommitdiff
path: root/internal/handlers/templates_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers/templates_test.go')
-rw-r--r--internal/handlers/templates_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/handlers/templates_test.go b/internal/handlers/templates_test.go
new file mode 100644
index 0000000..ffaf137
--- /dev/null
+++ b/internal/handlers/templates_test.go
@@ -0,0 +1,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)
+ }
+}