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

Function TestContextRenderNoContentIndentedJSON

context_test.go:1153–1162  ·  view source on GitHub ↗

Tests that no Custom JSON is rendered if code is 204

(t *testing.T)

Source from the content-addressed store, hash-verified

1151
1152// Tests that no Custom JSON is rendered if code is 204
1153func TestContextRenderNoContentIndentedJSON(t *testing.T) {
1154 w := httptest.NewRecorder()
1155 c, _ := CreateTestContext(w)
1156
1157 c.IndentedJSON(http.StatusNoContent, H{"foo": "bar", "bar": "foo", "nested": H{"foo": "bar"}})
1158
1159 assert.Equal(t, http.StatusNoContent, w.Code)
1160 assert.Empty(t, w.Body.String())
1161 assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))
1162}
1163
1164func TestContextClientIPWithMultipleHeaders(t *testing.T) {
1165 c, _ := CreateTestContext(httptest.NewRecorder())

Callers

nothing calls this directly

Calls 5

CreateTestContextFunction · 0.85
IndentedJSONMethod · 0.80
StringMethod · 0.65
GetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected