MCPcopy
hub / github.com/labstack/echo / TestRouter_Routes

Function TestRouter_Routes

router_test.go:2835–2869  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2833}
2834
2835func TestRouter_Routes(t *testing.T) {
2836 routes := []*Route{
2837 {Method: http.MethodGet, Path: "/users/:user/events"},
2838 {Method: http.MethodGet, Path: "/users/:user/events/public"},
2839 {Method: http.MethodPost, Path: "/repos/:owner/:repo/git/refs"},
2840 {Method: http.MethodPost, Path: "/repos/:owner/:repo/git/tags"},
2841 }
2842 router := NewRouter(RouterConfig{})
2843 for _, r := range routes {
2844 _, err := router.Add(Route{
2845 Method: r.Method,
2846 Path: r.Path,
2847 Handler: func(c *Context) error {
2848 return c.String(http.StatusOK, "OK")
2849 },
2850 })
2851 if err != nil {
2852 t.Fatal(err)
2853 }
2854 }
2855
2856 assert.Equal(t, len(routes), len(router.Routes()))
2857 for _, r := range router.Routes() {
2858 found := false
2859 for _, rr := range routes {
2860 if r.Method == rr.Method && r.Path == rr.Path {
2861 found = true
2862 break
2863 }
2864 }
2865 if !found {
2866 t.Errorf("Route %s %s not found", r.Method, r.Path)
2867 }
2868 }
2869}
2870
2871func TestRouterNoRoutablePath(t *testing.T) {
2872 e := New()

Callers

nothing calls this directly

Calls 4

AddMethod · 0.95
RoutesMethod · 0.95
NewRouterFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…