| 545 | } |
| 546 | |
| 547 | func TestMatchedRouteName(t *testing.T) { |
| 548 | routeName := "stock" |
| 549 | router := NewRouter() |
| 550 | route := router.NewRoute().Path("/products/").Name(routeName) |
| 551 | |
| 552 | url := "http://www.example.com/products/" |
| 553 | request, _ := http.NewRequest("GET", url, nil) |
| 554 | var rv RouteMatch |
| 555 | ok := router.Match(request, &rv) |
| 556 | |
| 557 | if !ok || rv.Route != route { |
| 558 | t.Errorf("Expected same route, got %+v.", rv.Route) |
| 559 | } |
| 560 | |
| 561 | retName := rv.Route.GetName() |
| 562 | if retName != routeName { |
| 563 | t.Errorf("Expected %q, got %q.", routeName, retName) |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | func TestSubRouting(t *testing.T) { |
| 568 | // Example from docs. |