1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-31 18:31:01 +00:00

fix(api): return 500 response when JSON serialization fails

This commit is contained in:
Frédéric Guillot 2025-01-30 18:06:30 -08:00
parent c951ac2876
commit 3ebeb38ade
3 changed files with 64 additions and 22 deletions

View file

@ -293,12 +293,12 @@ func TestBuildInvalidJSONResponse(t *testing.T) {
handler.ServeHTTP(w, r)
resp := w.Result()
expectedStatusCode := http.StatusOK
expectedStatusCode := http.StatusInternalServerError
if resp.StatusCode != expectedStatusCode {
t.Fatalf(`Unexpected status code, got %d instead of %d`, resp.StatusCode, expectedStatusCode)
}
expectedBody := ``
expectedBody := `{"error_message":"json: unsupported type: chan int"}`
actualBody := w.Body.String()
if actualBody != expectedBody {
t.Fatalf(`Unexpected body, got %s instead of %s`, actualBody, expectedBody)