(t *testing.T)
| 1601 | } |
| 1602 | |
| 1603 | func TestRouterMatchAnyMultiLevel(t *testing.T) { |
| 1604 | e := New() |
| 1605 | |
| 1606 | // Routes |
| 1607 | e.GET("/api/users/jack", handlerFunc) |
| 1608 | e.GET("/api/users/jill", handlerFunc) |
| 1609 | e.GET("/api/users/*", handlerFunc) |
| 1610 | e.GET("/api/*", handlerFunc) |
| 1611 | e.GET("/other/*", handlerFunc) |
| 1612 | e.GET("/*", handlerFunc) |
| 1613 | |
| 1614 | var testCases = []struct { |
| 1615 | expectRoute any |
| 1616 | expectError error |
| 1617 | expectParam map[string]string |
| 1618 | whenURL string |
| 1619 | }{ |
| 1620 | { |
| 1621 | whenURL: "/api/users/jack", |
| 1622 | expectRoute: "/api/users/jack", |
| 1623 | expectParam: map[string]string{"*": ""}, |
| 1624 | }, |
| 1625 | { |
| 1626 | whenURL: "/api/users/jill", |
| 1627 | expectRoute: "/api/users/jill", |
| 1628 | expectParam: map[string]string{"*": ""}, |
| 1629 | }, |
| 1630 | { |
| 1631 | whenURL: "/api/users/joe", |
| 1632 | expectRoute: "/api/users/*", |
| 1633 | expectParam: map[string]string{"*": "joe"}, |
| 1634 | }, |
| 1635 | { |
| 1636 | whenURL: "/api/nousers/joe", |
| 1637 | expectRoute: "/api/*", |
| 1638 | expectParam: map[string]string{"*": "nousers/joe"}, |
| 1639 | }, |
| 1640 | { |
| 1641 | whenURL: "/api/none", |
| 1642 | expectRoute: "/api/*", |
| 1643 | expectParam: map[string]string{"*": "none"}, |
| 1644 | }, |
| 1645 | { |
| 1646 | whenURL: "/api/none", |
| 1647 | expectRoute: "/api/*", |
| 1648 | expectParam: map[string]string{"*": "none"}, |
| 1649 | }, |
| 1650 | { |
| 1651 | whenURL: "/noapi/users/jim", |
| 1652 | expectRoute: "/*", |
| 1653 | expectParam: map[string]string{"*": "noapi/users/jim"}, |
| 1654 | }, |
| 1655 | } |
| 1656 | for _, tc := range testCases { |
| 1657 | t.Run(tc.whenURL, func(t *testing.T) { |
| 1658 | req := httptest.NewRequest(http.MethodGet, tc.whenURL, nil) |
| 1659 | c := e.NewContext(req, nil) |
| 1660 | handler := e.router.Route(c) |
nothing calls this directly
no test coverage detected
searching dependent graphs…