From 436d8e2af9198f5548a73cb96dbeb1cede403a5b Mon Sep 17 00:00:00 2001 From: Eason Lin Date: Thu, 6 Jul 2017 09:30:09 +0800 Subject: [PATCH] Improve serveError code coverage (#980) --- routes_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/routes_test.go b/routes_test.go index 7464d5d..41693ee 100644 --- a/routes_test.go +++ b/routes_test.go @@ -439,3 +439,15 @@ func TestRouteRawPathNoUnescape(t *testing.T) { w := performRequest(route, "POST", "/project/Some%2FOther%2FProject/build/333") assert.Equal(t, w.Code, 200) } + +func TestRouteServeErrorWithWriteHeader(t *testing.T) { + route := New() + route.Use(func(c *Context) { + c.Status(421) + c.Next() + }) + + w := performRequest(route, "GET", "/NotFound") + assert.Equal(t, 421, w.Code) + assert.Equal(t, 0, w.Body.Len()) +}