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

Method TestIntoWithError

server/server_test.go:207–222  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

205}
206
207func (s *ServerTestSuite) TestIntoWithError() {
208 testError := errctx.NewTextError("test error", 0)
209 mockHandler := func(reqID string, rw server.ResponseWriter, r *http.Request) *server.Error {
210 return server.NewError(testError, "test-category")
211 }
212
213 s.router().GET("/test", s.router().WithReportError(mockHandler))
214
215 req := httptest.NewRequest(http.MethodGet, "/test", nil)
216 rw := httptest.NewRecorder()
217
218 s.router().ServeHTTP(rw, req)
219
220 s.Equal(http.StatusInternalServerError, rw.Code)
221 s.Equal("text/plain", rw.Header().Get(httpheaders.ContentType))
222}
223
224func (s *ServerTestSuite) TestIntoPanicWithError() {
225 testError := errors.New("panic error")

Callers

nothing calls this directly

Calls 7

NewTextErrorFunction · 0.92
NewErrorFunction · 0.92
WithReportErrorMethod · 0.80
NewRequestMethod · 0.80
ServeHTTPMethod · 0.80
GetMethod · 0.65
GETMethod · 0.45

Tested by

no test coverage detected