Compare commits

...

2 Commits

Author SHA1 Message Date
ATUR
49f8073f9d
Merge 10349b43d11e65ddb82a5b3e803c581cce4d534d into f5c267d2f84ba8192dd9c4c67b0490abfa3dfe7a 2026-02-16 16:24:42 +05:30
aturzone
10349b43d1 test: add error tests for PureJSON and XML render types
Add missing error handling tests for PureJSON and XML render types
to improve test coverage. This addresses the TODO comment requesting
error tests in the render package.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 17:32:07 +03:30

View File

@ -249,6 +249,15 @@ func TestRenderPureJSON(t *testing.T) {
assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))
}
func TestRenderPureJSONFail(t *testing.T) {
w := httptest.NewRecorder()
data := make(chan int)
// json: unsupported type: chan int
err := (PureJSON{data}).Render(w)
require.Error(t, err)
}
type xmlmap map[string]any
// Allows type H to be used with xml.Marshal
@ -401,6 +410,15 @@ func TestRenderXML(t *testing.T) {
assert.Equal(t, "application/xml; charset=utf-8", w.Header().Get("Content-Type"))
}
func TestRenderXMLFail(t *testing.T) {
w := httptest.NewRecorder()
data := make(chan int)
// xml: unsupported type: chan int
err := (XML{data}).Render(w)
require.Error(t, err)
}
func TestRenderRedirect(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, "/test-redirect", nil)
require.NoError(t, err)