Odd/Even route listing testcase added

This commit is contained in:
Jithin James 2017-10-17 15:46:35 +05:30
parent 1e8fe69668
commit 688972b98c
3 changed files with 15 additions and 0 deletions

View File

@ -321,6 +321,10 @@ func handlerNameTest(c *Context) {
}
func handlerNameTest1(c *Context) {
}
var handlerTest HandlerFunc = func(c *Context) {
}

View File

@ -35,6 +35,7 @@ func getTerminalSize() int {
}
return width
}
func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
if IsDebugging() {
s := "<<<<<<<\tRunning Handlers\t>>>>>>>"

View File

@ -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) {