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

Method TestIntoPanicWithNonError

server/server_test.go:258–273  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

256}
257
258func (s *ServerTestSuite) TestIntoPanicWithNonError() {
259 mockHandler := func(reqID string, rw server.ResponseWriter, r *http.Request) *server.Error {
260 panic("string panic")
261 }
262
263 s.router().GET("/test", s.router().WithReportError(s.router().WithPanic(mockHandler)))
264
265 req := httptest.NewRequest(http.MethodGet, "/test", nil)
266 rw := httptest.NewRecorder()
267
268 s.NotPanics(func() {
269 s.router().ServeHTTP(rw, req)
270 })
271
272 s.Equal(http.StatusInternalServerError, rw.Code)
273}
274
275func (s *ServerTestSuite) mockHandler(reqID string, rw server.ResponseWriter, r *http.Request) *server.Error {
276 return nil

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