Test_App_Mount_Express_Behavior() — fiber Function Reference
Architecture documentation for the Test_App_Mount_Express_Behavior() function in mount_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD eaa8c07c_0883_2307_41c8_7bc52e4354fc["Test_App_Mount_Express_Behavior()"] dbd7cc10_1955_3f67_b103_5ae841223af0["mount_test.go"] eaa8c07c_0883_2307_41c8_7bc52e4354fc -->|defined in| dbd7cc10_1955_3f67_b103_5ae841223af0 style eaa8c07c_0883_2307_41c8_7bc52e4354fc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
mount_test.go lines 93–138
func Test_App_Mount_Express_Behavior(t *testing.T) {
t.Parallel()
createTestHandler := func(body string) func(c Ctx) error {
return func(c Ctx) error {
return c.SendString(body)
}
}
testEndpoint := func(app *App, route, expectedBody string, expectedStatusCode int) {
resp, err := app.Test(httptest.NewRequest(MethodGet, route, http.NoBody))
require.NoError(t, err, "app.Test(req)")
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, expectedStatusCode, resp.StatusCode, "Status code")
require.Equal(t, expectedBody, string(body), "Unexpected response body")
}
app := New()
subApp := New()
// app setup
subApp.Get("/hello", createTestHandler("subapp hello!"))
subApp.Get("/world", createTestHandler("subapp world!")) // <- wins
app.Get("/hello", createTestHandler("app hello!")) // <- wins
app.Use("/", subApp) // <- subApp registration
app.Get("/world", createTestHandler("app world!"))
app.Get("/bar", createTestHandler("app bar!"))
subApp.Get("/bar", createTestHandler("subapp bar!")) // <- wins
subApp.Get("/foo", createTestHandler("subapp foo!")) // <- wins
app.Get("/foo", createTestHandler("app foo!"))
// 404 Handler
app.Use(func(c Ctx) error {
return c.SendStatus(StatusNotFound)
})
// expectation check
testEndpoint(app, "/world", "subapp world!", StatusOK)
testEndpoint(app, "/hello", "app hello!", StatusOK)
testEndpoint(app, "/bar", "subapp bar!", StatusOK)
testEndpoint(app, "/foo", "subapp foo!", StatusOK)
testEndpoint(app, "/unknown", ErrNotFound.Message, StatusNotFound)
require.Equal(t, uint32(17), app.handlersCount)
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_App_Mount_Express_Behavior() do?
Test_App_Mount_Express_Behavior() is a function in the fiber codebase, defined in mount_test.go.
Where is Test_App_Mount_Express_Behavior() defined?
Test_App_Mount_Express_Behavior() is defined in mount_test.go at line 93.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free