| 1863 | } |
| 1864 | |
| 1865 | func Test_App_Route(t *testing.T) { |
| 1866 | t.Parallel() |
| 1867 | |
| 1868 | app := New() |
| 1869 | |
| 1870 | app.Route("/test", func(api Router) { |
| 1871 | api.Get("/foo", testEmptyHandler).Name("foo") |
| 1872 | |
| 1873 | api.Route("/bar", func(bar Router) { |
| 1874 | bar.Get("/", testEmptyHandler).Name("index") |
| 1875 | }, "bar.") |
| 1876 | }, "test.") |
| 1877 | |
| 1878 | testStatus200(t, app, "/test/foo", MethodGet) |
| 1879 | |
| 1880 | resp, err := app.Test(httptest.NewRequest(MethodGet, "/test/bar/", http.NoBody)) |
| 1881 | require.NoError(t, err, "app.Test(req)") |
| 1882 | require.Equal(t, http.StatusOK, resp.StatusCode, "Status code") |
| 1883 | |
| 1884 | require.Equal(t, "/test/foo", app.GetRoute("test.foo").Path) |
| 1885 | require.Equal(t, "/test/bar/", app.GetRoute("test.bar.index").Path) |
| 1886 | } |
| 1887 | |
| 1888 | func Test_App_Route_nilFuncPanics(t *testing.T) { |
| 1889 | t.Parallel() |