Home / Function/ TestRenderJSON() — gin Function Reference

TestRenderJSON() — gin Function Reference

Architecture documentation for the TestRenderJSON() function in render_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  939f1f84_7f6f_723d_03f9_60e37e3d257a["TestRenderJSON()"]
  067a4839_481a_7bd8_fc59_5c8c3313879c["render_test.go"]
  939f1f84_7f6f_723d_03f9_60e37e3d257a -->|defined in| 067a4839_481a_7bd8_fc59_5c8c3313879c
  style 939f1f84_7f6f_723d_03f9_60e37e3d257a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

render/render_test.go lines 29–44

func TestRenderJSON(t *testing.T) {
	w := httptest.NewRecorder()
	data := map[string]any{
		"foo":  "bar",
		"html": "<b>",
	}

	(JSON{data}).WriteContentType(w)
	assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))

	err := (JSON{data}).Render(w)

	require.NoError(t, err)
	assert.JSONEq(t, "{\"foo\":\"bar\",\"html\":\"\\u003cb\\u003e\"}", w.Body.String())
	assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))
}

Subdomains

Frequently Asked Questions

What does TestRenderJSON() do?
TestRenderJSON() is a function in the gin codebase, defined in render/render_test.go.
Where is TestRenderJSON() defined?
TestRenderJSON() is defined in render/render_test.go at line 29.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free