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

Function Test_App_Not_Use_StrictRouting

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

Source from the content-addressed store, hash-verified

917}
918
919func Test_App_Not_Use_StrictRouting(t *testing.T) {
920 t.Parallel()
921 app := New()
922
923 app.Use("/abc", func(c Ctx) error {
924 return c.SendString(c.Path())
925 })
926
927 g := app.Group("/foo")
928 g.Use("/", func(c Ctx) error {
929 return c.SendString(c.Path())
930 })
931
932 // wrong path in the requested route -> 404
933 resp, err := app.Test(httptest.NewRequest(MethodGet, "/abc/", http.NoBody))
934 require.NoError(t, err, "app.Test(req)")
935 require.Equal(t, StatusOK, resp.StatusCode, "Status code")
936
937 // right path in the requested route -> 200
938 resp, err = app.Test(httptest.NewRequest(MethodGet, "/abc", http.NoBody))
939 require.NoError(t, err, "app.Test(req)")
940 require.Equal(t, StatusOK, resp.StatusCode, "Status code")
941
942 // wrong path with group in the requested route -> 404
943 resp, err = app.Test(httptest.NewRequest(MethodGet, "/foo", http.NoBody))
944 require.NoError(t, err, "app.Test(req)")
945 require.Equal(t, StatusOK, resp.StatusCode, "Status code")
946
947 // right path with group in the requested route -> 200
948 resp, err = app.Test(httptest.NewRequest(MethodGet, "/foo/", http.NoBody))
949 require.NoError(t, err, "app.Test(req)")
950 require.Equal(t, StatusOK, resp.StatusCode, "Status code")
951}
952
953func Test_App_Use_MultiplePrefix(t *testing.T) {
954 t.Parallel()

Callers

nothing calls this directly

Calls 6

TestMethod · 0.80
NewFunction · 0.70
UseMethod · 0.65
SendStringMethod · 0.65
PathMethod · 0.65
GroupMethod · 0.65

Tested by

no test coverage detected