From 56f1a0621594a9f9440bea134dbc381630e038bf Mon Sep 17 00:00:00 2001 From: runner Date: Fri, 23 Dec 2016 15:22:05 +0800 Subject: [PATCH] add unit test of Context.RenderWith() add unit test of Context.RenderWith() --- context_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/context_test.go b/context_test.go index 01ee6b83..4b42b152 100644 --- a/context_test.go +++ b/context_test.go @@ -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) {