MCPcopy
hub / github.com/gin-gonic/gin / TestRenderIndentedJSON

Function TestRenderIndentedJSON

render/render_test.go:51–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestRenderIndentedJSON(t *testing.T) {
52 w := httptest.NewRecorder()
53 data := map[string]any{
54 "foo": "bar",
55 "bar": "foo",
56 }
57
58 err := (IndentedJSON{data}).Render(w)
59
60 require.NoError(t, err)
61 assert.JSONEq(t, "{\n \"bar\": \"foo\",\n \"foo\": \"bar\"\n}", w.Body.String())
62 assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))
63}
64
65func TestRenderIndentedJSONPanics(t *testing.T) {
66 w := httptest.NewRecorder()

Callers

nothing calls this directly

Calls 4

RenderMethod · 0.65
StringMethod · 0.65
GetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected