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

Function TestContextJSONWithEmptyIntent

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

Source from the content-addressed store, hash-verified

275}
276
277func TestContextJSONWithEmptyIntent(t *testing.T) {
278 e := New()
279 rec := httptest.NewRecorder()
280 req := httptest.NewRequest(http.MethodGet, "/", nil)
281 c := e.NewContext(req, rec)
282
283 u := user{ID: 1, Name: "Jon Snow"}
284 emptyIndent := ""
285 buf := new(bytes.Buffer)
286
287 enc := json.NewEncoder(buf)
288 enc.SetIndent(emptyIndent, emptyIndent)
289 _ = enc.Encode(u)
290 err := c.JSONPretty(http.StatusOK, user{ID: 1, Name: "Jon Snow"}, emptyIndent)
291 if assert.NoError(t, err) {
292 assert.Equal(t, http.StatusOK, rec.Code)
293 assert.Equal(t, MIMEApplicationJSON, rec.Header().Get(HeaderContentType))
294 assert.Equal(t, buf.String(), rec.Body.String())
295 }
296}
297
298func TestContextJSONP(t *testing.T) {
299 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…