add unit test of Context.RenderWith()

add unit test of Context.RenderWith()
This commit is contained in:
runner 2016-12-23 15:22:05 +08:00 committed by GitHub
parent 81b497afed
commit 56f1a06215

View File

@ -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) {