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

Function TestContextJSONPretty

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

Source from the content-addressed store, hash-verified

261}
262
263func TestContextJSONPretty(t *testing.T) {
264 e := New()
265 rec := httptest.NewRecorder()
266 req := httptest.NewRequest(http.MethodGet, "/", nil)
267 c := e.NewContext(req, rec)
268
269 err := c.JSONPretty(http.StatusOK, user{ID: 1, Name: "Jon Snow"}, " ")
270 if assert.NoError(t, err) {
271 assert.Equal(t, http.StatusOK, rec.Code)
272 assert.Equal(t, MIMEApplicationJSON, rec.Header().Get(HeaderContentType))
273 assert.Equal(t, userJSONPretty+"\n", rec.Body.String())
274 }
275}
276
277func TestContextJSONWithEmptyIntent(t *testing.T) {
278 e := New()

Callers

nothing calls this directly

Calls 6

JSONPrettyMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80
GetMethod · 0.45
HeaderMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…