Skip to content

Commit

Permalink
DebugPrintRouteFunc() unit test (#2395)
Browse files Browse the repository at this point in the history
Co-authored-by: thinkerou <thinkerou@gmail.com>
  • Loading branch information
pnvasanth and thinkerou committed May 25, 2020
1 parent c9b8535 commit 5e40c1d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions debug_test.go
Expand Up @@ -7,6 +7,7 @@ package gin
import (
"bytes"
"errors"
"fmt"
"html/template"
"io"
"log"
Expand Down Expand Up @@ -64,6 +65,18 @@ func TestDebugPrintRoutes(t *testing.T) {
assert.Regexp(t, `^\[GIN-debug\] GET /path/to/route/:param --> (.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest \(2 handlers\)\n$`, re)
}

func TestDebugPrintRouteFunc(t *testing.T) {
DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) {
fmt.Fprintf(DefaultWriter, "[GIN-debug] %-6s %-40s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers)
}
re := captureOutput(t, func() {
SetMode(DebugMode)
debugPrintRoute("GET", "/path/to/route/:param1/:param2", HandlersChain{func(c *Context) {}, handlerNameTest})
SetMode(TestMode)
})
assert.Regexp(t, `^\[GIN-debug\] GET /path/to/route/:param1/:param2 --> (.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest \(2 handlers\)\n$`, re)
}

func TestDebugPrintLoadTemplate(t *testing.T) {
re := captureOutput(t, func() {
SetMode(DebugMode)
Expand Down

0 comments on commit 5e40c1d

Please sign in to comment.