(t *testing.T)
| 1671 | } |
| 1672 | |
| 1673 | func TestWalkSubrouters(t *testing.T) { |
| 1674 | router := NewRouter() |
| 1675 | |
| 1676 | g := router.Path("/g").Subrouter() |
| 1677 | o := g.PathPrefix("/o").Subrouter() |
| 1678 | o.Methods("GET") |
| 1679 | o.Methods("PUT") |
| 1680 | |
| 1681 | // all 4 routes should be matched |
| 1682 | paths := []string{"/g", "/g/o", "/g/o", "/g/o"} |
| 1683 | idx := 0 |
| 1684 | err := router.Walk(func(route *Route, router *Router, ancestors []*Route) error { |
| 1685 | path := paths[idx] |
| 1686 | tpl, _ := route.GetPathTemplate() |
| 1687 | if tpl != path { |
| 1688 | t.Errorf(`Expected %s got %s`, path, tpl) |
| 1689 | } |
| 1690 | idx++ |
| 1691 | return nil |
| 1692 | }) |
| 1693 | if err != nil { |
| 1694 | panic(err) |
| 1695 | } |
| 1696 | if idx != len(paths) { |
| 1697 | t.Errorf("Expected %d routes, found %d", len(paths), idx) |
| 1698 | } |
| 1699 | } |
| 1700 | |
| 1701 | func TestWalkErrorRoute(t *testing.T) { |
| 1702 | router := NewRouter() |
nothing calls this directly
no test coverage detected