TestPanicWithAbort assert that panic has been recovered even if context.Abort was used.
(t *testing.T)
| 76 | |
| 77 | // TestPanicWithAbort assert that panic has been recovered even if context.Abort was used. |
| 78 | func 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 | |
| 91 | func TestFunction(t *testing.T) { |
| 92 | bs := function(1) |
nothing calls this directly
no test coverage detected