MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestIntoPanicWithError

Method TestIntoPanicWithError

server/server_test.go:224–240  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

222}
223
224func (s *ServerTestSuite) TestIntoPanicWithError() {
225 testError := errors.New("panic error")
226 mockHandler := func(reqID string, rw server.ResponseWriter, r *http.Request) *server.Error {
227 panic(testError)
228 }
229
230 s.router().GET("/test", s.router().WithReportError(s.router().WithPanic(mockHandler)))
231
232 req := httptest.NewRequest(http.MethodGet, "/test", nil)
233 rw := httptest.NewRecorder()
234
235 s.NotPanics(func() {
236 s.router().ServeHTTP(rw, req)
237 })
238
239 s.Equal(http.StatusInternalServerError, rw.Code)
240}
241
242func (s *ServerTestSuite) TestIntoPanicWithAbortHandler() {
243 mockHandler := func(reqID string, rw server.ResponseWriter, r *http.Request) *server.Error {

Callers

nothing calls this directly

Calls 5

WithReportErrorMethod · 0.80
WithPanicMethod · 0.80
NewRequestMethod · 0.80
ServeHTTPMethod · 0.80
GETMethod · 0.45

Tested by

no test coverage detected