refactor: use go:embed for templates
Templates are now embedded using //go:embed and parsed once at startup with template.Must(template.ParseFS(...)). This avoids re-parsing template files from disk on every request and removes the dependency on template files being present at runtime. closes #7
This commit is contained in:
@@ -87,10 +87,11 @@ func TestRenderTemplate(t *testing.T) {
|
||||
"Version": "1.0.0",
|
||||
}
|
||||
|
||||
// When templates don't exist, renderTemplate should return an error
|
||||
h.renderTemplate(w, req, []string{"nonexistent.html"}, data)
|
||||
// When a non-existent template name is requested, renderTemplate
|
||||
// should return an internal server error
|
||||
h.renderTemplate(w, req, "nonexistent.html", data)
|
||||
|
||||
// Should return internal server error when template parsing fails
|
||||
// Should return internal server error when template is not found
|
||||
assert.Equal(t, http.StatusInternalServerError, w.Code)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user