mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-15 04:57:07 +08:00
test: refactor context_test.go for clarity and efficiency
- Insert a `nil` value into the `HandlersChain` array in `context_test.go` - Remove empty test functions in `context_test.go` Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
4d3dfc8682
commit
b7e326d528
@ -362,7 +362,7 @@ func TestContextHandlerName(t *testing.T) {
|
|||||||
|
|
||||||
func TestContextHandlerNames(t *testing.T) {
|
func TestContextHandlerNames(t *testing.T) {
|
||||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||||
c.handlers = HandlersChain{func(c *Context) {}, handlerNameTest, func(c *Context) {}, handlerNameTest2}
|
c.handlers = HandlersChain{func(c *Context) {}, nil, handlerNameTest, func(c *Context) {}, handlerNameTest2}
|
||||||
|
|
||||||
names := c.HandlerNames()
|
names := c.HandlerNames()
|
||||||
|
|
||||||
@ -1671,7 +1671,6 @@ func TestContextBindWithXML(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestContextBindPlain(t *testing.T) {
|
func TestContextBindPlain(t *testing.T) {
|
||||||
|
|
||||||
// string
|
// string
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
c, _ := CreateTestContext(w)
|
c, _ := CreateTestContext(w)
|
||||||
@ -1863,7 +1862,6 @@ func TestContextShouldBindPlain(t *testing.T) {
|
|||||||
assert.NoError(t, c.ShouldBindPlain(&bs))
|
assert.NoError(t, c.ShouldBindPlain(&bs))
|
||||||
assert.Equal(t, []byte("test []byte"), bs)
|
assert.Equal(t, []byte("test []byte"), bs)
|
||||||
assert.Equal(t, 0, w.Body.Len())
|
assert.Equal(t, 0, w.Body.Len())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContextShouldBindHeader(t *testing.T) {
|
func TestContextShouldBindHeader(t *testing.T) {
|
||||||
@ -2371,6 +2369,7 @@ func TestContextShouldBindBodyWithPlain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContextGolangContext(t *testing.T) {
|
func TestContextGolangContext(t *testing.T) {
|
||||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||||
c.Request, _ = http.NewRequest("POST", "/", bytes.NewBufferString("{\"foo\":\"bar\", \"bar\":\"foo\"}"))
|
c.Request, _ = http.NewRequest("POST", "/", bytes.NewBufferString("{\"foo\":\"bar\", \"bar\":\"foo\"}"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user