mirror of
https://github.com/gin-gonic/gin.git
synced 2025-05-20 17:06:24 +08:00
test: expose performRequest func (#3012)
This commit is contained in:
@ -45,11 +45,11 @@ func TestWrap(t *testing.T) {
|
||||
fmt.Fprint(w, "hola!")
|
||||
}))
|
||||
|
||||
w := performRequest(router, "POST", "/path")
|
||||
w := PerformRequest(router, "POST", "/path")
|
||||
assert.Equal(t, http.StatusInternalServerError, w.Code)
|
||||
assert.Equal(t, "hello", w.Body.String())
|
||||
|
||||
w = performRequest(router, "GET", "/path2")
|
||||
w = PerformRequest(router, "GET", "/path2")
|
||||
assert.Equal(t, http.StatusBadRequest, w.Code)
|
||||
assert.Equal(t, "hola!", w.Body.String())
|
||||
}
|
||||
@ -119,13 +119,13 @@ func TestBindMiddleware(t *testing.T) {
|
||||
called = true
|
||||
value = c.MustGet(BindKey).(*bindTestStruct)
|
||||
})
|
||||
performRequest(router, "GET", "/?foo=hola&bar=10")
|
||||
PerformRequest(router, "GET", "/?foo=hola&bar=10")
|
||||
assert.True(t, called)
|
||||
assert.Equal(t, "hola", value.Foo)
|
||||
assert.Equal(t, 10, value.Bar)
|
||||
|
||||
called = false
|
||||
performRequest(router, "GET", "/?foo=hola&bar=1")
|
||||
PerformRequest(router, "GET", "/?foo=hola&bar=1")
|
||||
assert.False(t, called)
|
||||
|
||||
assert.Panics(t, func() {
|
||||
|
Reference in New Issue
Block a user