(t *testing.T)
| 246 | } |
| 247 | |
| 248 | func TestContextJSONWithNotEchoResponse(t *testing.T) { |
| 249 | e := New() |
| 250 | rec := httptest.NewRecorder() |
| 251 | req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(userJSON)) |
| 252 | c := e.NewContext(req, rec) |
| 253 | |
| 254 | c.SetResponse(rec) |
| 255 | |
| 256 | err := c.JSON(http.StatusCreated, map[string]float64{"foo": math.NaN()}) |
| 257 | assert.EqualError(t, err, "json: unsupported value: NaN") |
| 258 | |
| 259 | assert.Equal(t, http.StatusOK, rec.Code) // status code must not be sent to the client |
| 260 | assert.Empty(t, rec.Body.String()) // body must not be sent to the client |
| 261 | } |
| 262 | |
| 263 | func TestContextJSONPretty(t *testing.T) { |
| 264 | e := New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…