MCPcopy
hub / github.com/gofiber/fiber / Test_App_Route

Function Test_App_Route

app_test.go:1865–1886  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1863}
1864
1865func 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
1888func Test_App_Route_nilFuncPanics(t *testing.T) {
1889 t.Parallel()

Callers

nothing calls this directly

Calls 7

testStatus200Function · 0.85
TestMethod · 0.80
GetRouteMethod · 0.80
NewFunction · 0.70
RouteMethod · 0.65
NameMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected