MCPcopy Index your code
hub / github.com/labstack/echo / TestContextJSONWithNotEchoResponse

Function TestContextJSONWithNotEchoResponse

context_test.go:248–261  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

246}
247
248func 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
263func TestContextJSONPretty(t *testing.T) {
264 e := New()

Callers

nothing calls this directly

Calls 5

SetResponseMethod · 0.95
JSONMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…