mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-24 02:32:17 +08:00
Odd/Even route listing testcase added
This commit is contained in:
parent
1e8fe69668
commit
688972b98c
@ -321,6 +321,10 @@ func handlerNameTest(c *Context) {
|
||||
|
||||
}
|
||||
|
||||
func handlerNameTest1(c *Context) {
|
||||
|
||||
}
|
||||
|
||||
var handlerTest HandlerFunc = func(c *Context) {
|
||||
|
||||
}
|
||||
|
1
debug.go
1
debug.go
@ -35,6 +35,7 @@ func getTerminalSize() int {
|
||||
}
|
||||
return width
|
||||
}
|
||||
|
||||
func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
|
||||
if IsDebugging() {
|
||||
s := "<<<<<<<\tRunning Handlers\t>>>>>>>"
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user