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

Function TestContext_JSON_CommitsCustomResponseCode

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

Source from the content-addressed store, hash-verified

409}
410
411func TestContext_JSON_CommitsCustomResponseCode(t *testing.T) {
412 e := New()
413 req := httptest.NewRequest(http.MethodGet, "/", nil)
414 rec := httptest.NewRecorder()
415 c := e.NewContext(req, rec)
416 err := c.JSON(http.StatusCreated, user{ID: 1, Name: "Jon Snow"})
417
418 if assert.NoError(t, err) {
419 assert.Equal(t, http.StatusCreated, rec.Code)
420 assert.Equal(t, MIMEApplicationJSON, rec.Header().Get(HeaderContentType))
421 assert.Equal(t, userJSON+"\n", rec.Body.String())
422 }
423}
424
425func TestContextAttachment(t *testing.T) {
426 var testCases = []struct {

Callers

nothing calls this directly

Calls 6

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