MCPcopy Index your code
hub / github.com/labstack/echo / TestHandlerName

Function TestHandlerName

route_test.go:25–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23}
24
25func TestHandlerName(t *testing.T) {
26 myNameFuncVar := func(c *Context) error {
27 return nil
28 }
29
30 tmp := NameStruct{}
31
32 var testCases = []struct {
33 name string
34 whenHandlerFunc HandlerFunc
35 expect string
36 }{
37 {
38 name: "ok, func as anonymous func",
39 whenHandlerFunc: func(c *Context) error {
40 return nil
41 },
42 expect: "github.com/labstack/echo/v5.TestHandlerName.func2",
43 },
44 {
45 name: "ok, func as named package variable",
46 whenHandlerFunc: myNamedHandler,
47 expect: "github.com/labstack/echo/v5.init.func4",
48 },
49 {
50 name: "ok, func as named function variable",
51 whenHandlerFunc: myNameFuncVar,
52 expect: "github.com/labstack/echo/v5.TestHandlerName.func1",
53 },
54 {
55 name: "ok, func as struct method",
56 whenHandlerFunc: tmp.getUsers,
57 expect: "github.com/labstack/echo/v5.(*NameStruct).getUsers-fm",
58 },
59 }
60
61 for _, tc := range testCases {
62 t.Run(tc.name, func(t *testing.T) {
63 name := HandlerName(tc.whenHandlerFunc)
64 assert.Equal(t, tc.expect, name)
65 })
66 }
67}
68
69func TestHandlerName_differentFuncSameName(t *testing.T) {
70 handlerCreator := func(name string) HandlerFunc {

Callers

nothing calls this directly

Calls 1

HandlerNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…