Skip to content
Myr

DebugPrintRouteFunc() unit test (#2395)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Vas N · committed by GitHub · parent c9b8535 · Browse files · 1 file+13 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: thinkerou <thinkerou@gmail.com>

Diff stats

1 file+13 added−0 removed

  • other:+13 added−0 removed

1 file+13 added−0 removed

modified:debug_test.go+13 added
5 unmodified lines
67import (8 "bytes"9 "errors"10 "fmt"11 "html/template"12 "io"13 "log"14 "os"
49 unmodified lines
64 })65 assert.Regexp(t, `^\[GIN-debug\] GET /path/to/route/:param --> (.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest \(2 handlers\)\n$`, re)66}6768func TestDebugPrintRouteFunc(t *testing.T) {69 DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) {70 fmt.Fprintf(DefaultWriter, "[GIN-debug] %-6s %-40s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers)71 }72 re := captureOutput(t, func() {73 SetMode(DebugMode)74 debugPrintRoute("GET", "/path/to/route/:param1/:param2", HandlersChain{func(c *Context) {}, handlerNameTest})75 SetMode(TestMode)76 })77 assert.Regexp(t, `^\[GIN-debug\] GET /path/to/route/:param1/:param2 --> (.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest \(2 handlers\)\n$`, re)78}7980func TestDebugPrintLoadTemplate(t *testing.T) {81 re := captureOutput(t, func() {82 SetMode(DebugMode)83 templ := template.Must(template.New("").Delims("{[{", "}]}").ParseGlob("./testdata/template/hello.tmpl"))
83 unmodified lines