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

Function testRouterAPI

router_test.go:2217–2246  ·  view source on GitHub ↗
(t *testing.T, api []testRoute)

Source from the content-addressed store, hash-verified

2215}
2216
2217func testRouterAPI(t *testing.T, api []testRoute) {
2218 e := New()
2219
2220 for _, route := range api {
2221 ri, err := e.AddRoute(Route{
2222 Method: route.Method,
2223 Path: route.Path,
2224 Handler: func(c *Context) error {
2225 return nil
2226 },
2227 })
2228 assert.NoError(t, err)
2229 assert.NotNil(t, ri)
2230 }
2231
2232 c := e.NewContext(nil, nil)
2233 for _, route := range api {
2234 t.Run(route.Path, func(t *testing.T) {
2235 c.SetRequest(httptest.NewRequest(route.Method, route.Path, nil))
2236 e.router.Route(c)
2237
2238 tokens := strings.SplitSeq(route.Path[1:], "/")
2239 for token := range tokens {
2240 if token[0] == ':' {
2241 assert.Equal(t, c.pathValues.GetOr(token[1:], "---none---"), token)
2242 }
2243 }
2244 })
2245 }
2246}
2247
2248func TestRouterGitHubAPI(t *testing.T) {
2249 testRouterAPI(t, gitHubAPI)

Callers 4

TestRouterGitHubAPIFunction · 0.85
TestRouterParamAliasFunction · 0.85
TestRouterParamOrderingFunction · 0.85
TestRouterMixedParamsFunction · 0.85

Calls 6

SetRequestMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80
GetOrMethod · 0.80
RouteMethod · 0.65
AddRouteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…