TestPanicInHandler() — gin Function Reference
Architecture documentation for the TestPanicInHandler() function in recovery_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD c7bd4f13_b024_275f_1566_3f5b976fc25f["TestPanicInHandler()"] c9a553a7_05a4_91a7_23b0_924f9f59d021["recovery_test.go"] c7bd4f13_b024_275f_1566_3f5b976fc25f -->|defined in| c9a553a7_05a4_91a7_23b0_924f9f59d021 style c7bd4f13_b024_275f_1566_3f5b976fc25f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
recovery_test.go lines 50–75
func TestPanicInHandler(t *testing.T) {
buffer := new(strings.Builder)
router := New()
router.Use(RecoveryWithWriter(buffer))
router.GET("/recovery", func(_ *Context) {
panic("Oupps, Houston, we have a problem")
})
// RUN
w := PerformRequest(router, http.MethodGet, "/recovery")
// TEST
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, buffer.String(), "panic recovered")
assert.Contains(t, buffer.String(), "Oupps, Houston, we have a problem")
assert.Contains(t, buffer.String(), t.Name())
assert.NotContains(t, buffer.String(), "GET /recovery")
// Debug mode prints the request
SetMode(DebugMode)
// RUN
w = PerformRequest(router, http.MethodGet, "/recovery")
// TEST
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, buffer.String(), "GET /recovery")
SetMode(TestMode)
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestPanicInHandler() do?
TestPanicInHandler() is a function in the gin codebase, defined in recovery_test.go.
Where is TestPanicInHandler() defined?
TestPanicInHandler() is defined in recovery_test.go at line 50.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free