mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 21:32:11 +08:00
add unit test of Context.RenderWith()
add unit test of Context.RenderWith()
This commit is contained in:
parent
81b497afed
commit
56f1a06215
@ -347,6 +347,22 @@ func TestContextGetCookie(t *testing.T) {
|
||||
assert.Equal(t, cookie, "gin")
|
||||
}
|
||||
|
||||
type panicRender struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (r panicRender) Render(w http.ResponseWriter) error {
|
||||
return r.err
|
||||
}
|
||||
|
||||
// Tests that render fail and return a error
|
||||
func TestContextRenderWith(t *testing.T) {
|
||||
c, _, _ := CreateTestContext()
|
||||
excepted := errors.New("render fail")
|
||||
actual := c.RenderWith(200, panicRender{err: excepted})
|
||||
assert.Equal(t, actual, actual)
|
||||
}
|
||||
|
||||
// Tests that the response is serialized as JSON
|
||||
// and Content-Type is set to application/json
|
||||
func TestContextRenderJSON(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user