summaryrefslogtreecommitdiff
path: root/internal/handlers/handlers_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers/handlers_test.go')
-rw-r--r--internal/handlers/handlers_test.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go
index 3367ef6..96cb911 100644
--- a/internal/handlers/handlers_test.go
+++ b/internal/handlers/handlers_test.go
@@ -64,11 +64,16 @@ func setupTestDB(t *testing.T) (*store.Store, func()) {
func loadTestTemplates(t *testing.T) *template.Template {
t.Helper()
+ // Template functions (must match handlers.go)
+ funcMap := template.FuncMap{
+ "subtract": func(a, b int) int { return a - b },
+ }
+
// Get path relative to project root
- tmpl, err := template.ParseGlob(filepath.Join("web", "templates", "*.html"))
+ tmpl, err := template.New("").Funcs(funcMap).ParseGlob(filepath.Join("web", "templates", "*.html"))
if err != nil {
// Try from internal/handlers (2 levels up)
- tmpl, err = template.ParseGlob(filepath.Join("..", "..", "web", "templates", "*.html"))
+ tmpl, err = template.New("").Funcs(funcMap).ParseGlob(filepath.Join("..", "..", "web", "templates", "*.html"))
if err != nil {
t.Logf("Warning: failed to parse templates: %v", err)
return nil