| 46 | } |
| 47 | |
| 48 | func TestResolvedHandler(t *testing.T) { |
| 49 | t.Parallel() |
| 50 | |
| 51 | tests := []struct { |
| 52 | method string |
| 53 | path string |
| 54 | handler echo.HandlerFunc |
| 55 | middlewares []echo.MiddlewareFunc |
| 56 | }{ |
| 57 | {"GET", "/path1", testHandlerFunc, nil}, |
| 58 | {"POST", "/path2", testHandlerFunc, []echo.MiddlewareFunc{testMiddlewareFunc}}, |
| 59 | {"PUT", "/path3", testHandlerFunc, []echo.MiddlewareFunc{testMiddlewareFunc, testMiddlewareFunc}}, |
| 60 | } |
| 61 | |
| 62 | for _, tt := range tests { |
| 63 | tt := tt |
| 64 | |
| 65 | t.Run(tt.method+tt.path, func(t *testing.T) { |
| 66 | t.Parallel() |
| 67 | |
| 68 | rh := fxhttpserver.NewResolvedHandler(tt.method, tt.path, tt.handler, tt.middlewares...) |
| 69 | |
| 70 | assert.Equal(t, tt.method, rh.Method()) |
| 71 | assert.Equal(t, tt.path, rh.Path()) |
| 72 | assert.Equal(t, "custom error", rh.Handler()(nil).Error()) |
| 73 | assert.Equal(t, tt.middlewares, rh.Middlewares()) |
| 74 | }) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func TestResolvedHandlersGroup(t *testing.T) { |
| 79 | t.Parallel() |