|
@@ -340,10 +340,26 @@ func TestContextHandlerName(t *testing.T) {
|
|
|
assert.Regexp(t, "^(.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest$", c.HandlerName())
|
|
assert.Regexp(t, "^(.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest$", c.HandlerName())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func TestContextHandlerNames(t *testing.T) {
|
|
|
|
|
+ c, _ := CreateTestContext(httptest.NewRecorder())
|
|
|
|
|
+ c.handlers = HandlersChain{func(c *Context) {}, handlerNameTest, func(c *Context) {}, handlerNameTest2}
|
|
|
|
|
+
|
|
|
|
|
+ names := c.HandlerNames()
|
|
|
|
|
+
|
|
|
|
|
+ assert.True(t, len(names) == 4)
|
|
|
|
|
+ for _, name := range names {
|
|
|
|
|
+ assert.Regexp(t, `^(.*/vendor/)?(github\.com/gin-gonic/gin\.){1}(TestContextHandlerNames\.func.*){0,1}(handlerNameTest.*){0,1}`, name)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func handlerNameTest(c *Context) {
|
|
func handlerNameTest(c *Context) {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func handlerNameTest2(c *Context) {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
var handlerTest HandlerFunc = func(c *Context) {
|
|
var handlerTest HandlerFunc = func(c *Context) {
|
|
|
|
|
|
|
|
}
|
|
}
|