From 688972b98c4bc658600f9dbda94da8435930c0ae Mon Sep 17 00:00:00 2001 From: Jithin James Date: Tue, 17 Oct 2017 15:46:35 +0530 Subject: [PATCH] Odd/Even route listing testcase added --- context_test.go | 4 ++++ debug.go | 1 + debug_test.go | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/context_test.go b/context_test.go index 4854a8a8..56372336 100644 --- a/context_test.go +++ b/context_test.go @@ -321,6 +321,10 @@ func handlerNameTest(c *Context) { } +func handlerNameTest1(c *Context) { + +} + var handlerTest HandlerFunc = func(c *Context) { } diff --git a/debug.go b/debug.go index ac53f4a4..fde7e730 100644 --- a/debug.go +++ b/debug.go @@ -35,6 +35,7 @@ func getTerminalSize() int { } return width } + func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) { if IsDebugging() { s := "<<<<<<<\tRunning Handlers\t>>>>>>>" diff --git a/debug_test.go b/debug_test.go index a351232d..042d45b0 100644 --- a/debug_test.go +++ b/debug_test.go @@ -64,10 +64,20 @@ func TestDebugPrintRoutes(t *testing.T) { setup(&w) defer teardown() + // Even routes debugPrintRoute("GET", "/path/to/route/:param", HandlersChain{func(c *Context) {}, handlerNameTest}) s := w.String() lines := strings.Split(s, "\n") assert.Regexp(t, `^\[GIN-debug\] GET /path/to/route/:param --> (.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest \(2 handlers\)\n$`, lines[len(lines)-2]+"\n") + + // Odd routes + setup(&w) + defer teardown() + + debugPrintRoute("GET", "/path/to/route/:param", HandlersChain{func(c *Context) {}, handlerNameTest, handlerNameTest1}) + s = w.String() + lines = strings.Split(s, "\n") + assert.Regexp(t, `^\[GIN-debug\] GET /path/to/route/:param --> (.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest \(3 handlers\)\n$`, lines[len(lines)-2]+"\n") } func TestDebugPrintLoadTemplate(t *testing.T) {