MCPcopy Create free account
hub / github.com/ankorstore/yokai / TestResolvedHandler

Function TestResolvedHandler

fxhttpserver/resolve_test.go:48–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func 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
78func TestResolvedHandlersGroup(t *testing.T) {
79 t.Parallel()

Callers

nothing calls this directly

Calls 6

MethodMethod · 0.95
PathMethod · 0.95
HandlerMethod · 0.95
MiddlewaresMethod · 0.95
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected