Skip to content

Commit

Permalink
test: refactor context_test.go for clarity and efficiency
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
appleboy committed May 13, 2024
1 parent 4d3dfc8 commit b7e326d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func TestContextHandlerName(t *testing.T) {

func TestContextHandlerNames(t *testing.T) {
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()

Expand Down Expand Up @@ -1671,7 +1671,6 @@ func TestContextBindWithXML(t *testing.T) {
}

func TestContextBindPlain(t *testing.T) {

// string
w := httptest.NewRecorder()
c, _ := CreateTestContext(w)
Expand Down Expand Up @@ -1863,7 +1862,6 @@ func TestContextShouldBindPlain(t *testing.T) {
assert.NoError(t, c.ShouldBindPlain(&bs))
assert.Equal(t, []byte("test []byte"), bs)
assert.Equal(t, 0, w.Body.Len())

}

func TestContextShouldBindHeader(t *testing.T) {
Expand Down Expand Up @@ -2371,6 +2369,7 @@ func TestContextShouldBindBodyWithPlain(t *testing.T) {
}
}
}

func TestContextGolangContext(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.Request, _ = http.NewRequest("POST", "/", bytes.NewBufferString("{\"foo\":\"bar\", \"bar\":\"foo\"}"))
Expand Down

0 comments on commit b7e326d

Please sign in to comment.