MCPcopy Create free account
hub / github.com/pace/bricks / TestHandlerError

Function TestHandlerError

http/jsonapi/generator/internal/pay/pay_test.go:264–284  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

262}
263
264func TestHandlerError(t *testing.T) {
265 r := Router(&testService{t}, &testAuthBackend{})
266 rec := httptest.NewRecorder()
267 req := httptest.NewRequest("GET", "/pay/beta/payment-methods", nil)
268 req.Header.Set("Accept", runtime.JSONAPIContentType)
269 req.Header.Set("Content-Type", runtime.JSONAPIContentType)
270
271 log.Handler()(r).ServeHTTP(rec, req)
272
273 resp := rec.Result()
274 defer resp.Body.Close()
275
276 if resp.StatusCode != http.StatusInternalServerError {
277 t.Errorf("expected 500 got: %d", resp.StatusCode)
278 b, err := io.ReadAll(resp.Body)
279 if err != nil {
280 t.Fatal(err)
281 }
282 t.Error(string(b[:]))
283 }
284}

Callers

nothing calls this directly

Calls 8

HandlerFunction · 0.92
SetMethod · 0.80
CloseMethod · 0.80
ErrorfMethod · 0.80
FatalMethod · 0.80
RouterFunction · 0.70
ServeHTTPMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…