From 9f35f7149d8fb790bbe8e4f0ee74f895aea1fc58 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Tue, 3 Feb 2026 15:15:07 -1000 Subject: Refactor template rendering with Renderer interface for testability Introduce a Renderer interface to abstract template rendering, enabling tests to use MockRenderer instead of requiring real template files. Changes: - Add renderer.go with Renderer interface, TemplateRenderer, and MockRenderer - Update Handler struct to use Renderer instead of *template.Template - Update HTMLResponse() to accept Renderer interface - Replace all h.templates.ExecuteTemplate() calls with h.renderer.Render() - Update all tests to use MockRenderer, removing template file dependencies This eliminates 15+ tests that previously skipped with "Templates not available" and improves test isolation. Co-Authored-By: Claude Opus 4.5 --- internal/handlers/timeline.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'internal/handlers/timeline.go') diff --git a/internal/handlers/timeline.go b/internal/handlers/timeline.go index fa5bcec..29b156a 100644 --- a/internal/handlers/timeline.go +++ b/internal/handlers/timeline.go @@ -109,7 +109,7 @@ func (h *Handler) HandleTimeline(w http.ResponseWriter, r *http.Request) { data.TomorrowHours = append(data.TomorrowHours, h) } - HTMLResponse(w, h.templates, "timeline-tab", data) + HTMLResponse(w, h.renderer, "timeline-tab", data) } // calcCalendarBounds returns start/end hours for calendar view based on timed events. -- cgit v1.2.3