MCPcopy
hub / github.com/labstack/echo / TestContextJSONErrorsOut

Function TestContextJSONErrorsOut

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

Source from the content-addressed store, hash-verified

233}
234
235func TestContextJSONErrorsOut(t *testing.T) {
236 e := New()
237 rec := httptest.NewRecorder()
238 req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(userJSON))
239 c := e.NewContext(req, rec)
240
241 err := c.JSON(http.StatusOK, make(chan bool))
242 assert.EqualError(t, err, "json: unsupported type: chan bool")
243
244 assert.Equal(t, http.StatusOK, rec.Code) // status code must not be sent to the client
245 assert.Empty(t, rec.Body.String()) // body must not be sent to the client
246}
247
248func TestContextJSONWithNotEchoResponse(t *testing.T) {
249 e := New()

Callers

nothing calls this directly

Calls 4

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…