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

Function TestContextJSONBlob

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

Source from the content-addressed store, hash-verified

311}
312
313func TestContextJSONBlob(t *testing.T) {
314 e := New()
315 rec := httptest.NewRecorder()
316 req := httptest.NewRequest(http.MethodGet, "/", nil)
317 c := e.NewContext(req, rec)
318
319 data, err := json.Marshal(user{ID: 1, Name: "Jon Snow"})
320 assert.NoError(t, err)
321 err = c.JSONBlob(http.StatusOK, data)
322 if assert.NoError(t, err) {
323 assert.Equal(t, http.StatusOK, rec.Code)
324 assert.Equal(t, MIMEApplicationJSON, rec.Header().Get(HeaderContentType))
325 assert.Equal(t, userJSON, rec.Body.String())
326 }
327}
328
329func TestContextJSONPBlob(t *testing.T) {
330 e := New()

Callers

nothing calls this directly

Calls 6

JSONBlobMethod · 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…