MCPcopy
hub / github.com/gorilla/mux / TestMatchedRouteName

Function TestMatchedRouteName

old_test.go:547–565  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

545}
546
547func 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
567func TestSubRouting(t *testing.T) {
568 // Example from docs.

Callers

nothing calls this directly

Calls 6

NewRouteMethod · 0.95
MatchMethod · 0.95
NewRouterFunction · 0.85
GetNameMethod · 0.80
NameMethod · 0.45
PathMethod · 0.45

Tested by

no test coverage detected