mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-23 01:57:55 +08:00
Fix tests style
This commit is contained in:
parent
5c704908d8
commit
f01951917b
@ -575,9 +575,9 @@ func TestContextRenderJSON(t *testing.T) {
|
|||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
c, _ := CreateTestContext(w)
|
c, _ := CreateTestContext(w)
|
||||||
|
|
||||||
c.JSON(http.StatusCreated, H{"foo": "bar", "html": "<b>"})
|
c.JSON(201, H{"foo": "bar", "html": "<b>"})
|
||||||
|
|
||||||
assert.Equal(t, http.StatusCreated, w.Code)
|
assert.Equal(t, 201, w.Code)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
"{\"foo\":\"bar\",\"html\":\"\\u003cb\\u003e\"}\n",
|
"{\"foo\":\"bar\",\"html\":\"\\u003cb\\u003e\"}\n",
|
||||||
@ -591,7 +591,7 @@ func TestContextRenderJSON(t *testing.T) {
|
|||||||
func TestContextRenderPureJSON(t *testing.T) {
|
func TestContextRenderPureJSON(t *testing.T) {
|
||||||
c, w, _ := CreateTestContext()
|
c, w, _ := CreateTestContext()
|
||||||
c.PureJSON(201, H{"foo": "bar", "html": "<b>"})
|
c.PureJSON(201, H{"foo": "bar", "html": "<b>"})
|
||||||
assert.Equal(t, w.Code, 201)
|
assert.Equal(t, 201, w.Code)
|
||||||
assert.Equal(t, "{\"foo\":\"bar\",\"html\":\"<b>\"}\n", w.Body.String())
|
assert.Equal(t, "{\"foo\":\"bar\",\"html\":\"<b>\"}\n", w.Body.String())
|
||||||
assert.Equal(t, "application/json; charset=utf-8", w.HeaderMap.Get("Content-Type"))
|
assert.Equal(t, "application/json; charset=utf-8", w.HeaderMap.Get("Content-Type"))
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,9 @@ func TestRenderJSON(t *testing.T) {
|
|||||||
assert.Equal(t, "{\"foo\":\"bar\"}", w.Body.String())
|
assert.Equal(t, "{\"foo\":\"bar\"}", w.Body.String())
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
w.Body.String(),
|
"{\"foo\":\"bar\",\"html\":\"\\u003cb\\u003e\"}\n",
|
||||||
"{\"foo\":\"bar\",\"html\":\"\\u003cb\\u003e\"}\n")
|
w.Body.String())
|
||||||
assert.Equal(t, w.Header().Get("Content-Type"), "application/json; charset=utf-8")
|
assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRenderPureJSON(t *testing.T) {
|
func TestRenderPureJSON(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user