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:
parent
c951ac2876
commit
3ebeb38ade
3 changed files with 64 additions and 22 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue