MCPcopy
hub / github.com/gin-gonic/gin / TestPanicWithAbort

Function TestPanicWithAbort

recovery_test.go:78–89  ·  view source on GitHub ↗

TestPanicWithAbort assert that panic has been recovered even if context.Abort was used.

(t *testing.T)

Source from the content-addressed store, hash-verified

76
77// TestPanicWithAbort assert that panic has been recovered even if context.Abort was used.
78func TestPanicWithAbort(t *testing.T) {
79 router := New()
80 router.Use(RecoveryWithWriter(nil))
81 router.GET("/recovery", func(c *Context) {
82 c.AbortWithStatus(http.StatusBadRequest)
83 panic("Oops, Houston, we have a problem")
84 })
85 // RUN
86 w := PerformRequest(router, http.MethodGet, "/recovery")
87 // TEST
88 assert.Equal(t, http.StatusBadRequest, w.Code)
89}
90
91func TestFunction(t *testing.T) {
92 bs := function(1)

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
RecoveryWithWriterFunction · 0.85
PerformRequestFunction · 0.85
AbortWithStatusMethod · 0.80
UseMethod · 0.65
GETMethod · 0.65

Tested by

no test coverage detected