mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-15 21:06:39 +08:00
Added relevant unit test.
This commit is contained in:
parent
19bf52b5bd
commit
7d753188a7
@ -219,6 +219,17 @@ func TestContextRenderJSON(t *testing.T) {
|
|||||||
assert.Equal(t, w.HeaderMap.Get("Content-Type"), "application/json; charset=utf-8")
|
assert.Equal(t, w.HeaderMap.Get("Content-Type"), "application/json; charset=utf-8")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests that the response is serialized as JSON
|
||||||
|
// and Content-Type is set to application/vnd.api+json
|
||||||
|
func TestContextRenderJSON(t *testing.T) {
|
||||||
|
c, w, _ := createTestContext()
|
||||||
|
c.JSONAPI(201, H{"foo": "bar"})
|
||||||
|
|
||||||
|
assert.Equal(t, w.Code, 201)
|
||||||
|
assert.Equal(t, w.Body.String(), "{\"foo\":\"bar\"}\n")
|
||||||
|
assert.Equal(t, w.HeaderMap.Get("Content-Type"), "application/vnd.api+json")
|
||||||
|
}
|
||||||
|
|
||||||
// Tests that the response is serialized as JSON
|
// Tests that the response is serialized as JSON
|
||||||
// and Content-Type is set to application/json
|
// and Content-Type is set to application/json
|
||||||
func TestContextRenderIndentedJSON(t *testing.T) {
|
func TestContextRenderIndentedJSON(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user