MCPcopy Create free account
hub / github.com/chain/Core / TestReadErr

Function TestReadErr

net/http/httpjson/handler_test.go:68–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestReadErr(t *testing.T) {
69 var gotErr error
70 errFunc := func(ctx context.Context, w http.ResponseWriter, err error) {
71 gotErr = errors.Root(err)
72 }
73 h, _ := Handler(func(int) {}, errFunc)
74
75 resp := httptest.NewRecorder()
76 body := iotest.OneByteReader(iotest.TimeoutReader(strings.NewReader("123456")))
77 req, _ := http.NewRequest("GET", "/", body)
78 h.ServeHTTP(resp, req)
79 if got := resp.Body.Len(); got != 0 {
80 t.Errorf("len(response) = %d want 0", got)
81 }
82 wantErr := ErrBadRequest
83 if gotErr != wantErr {
84 t.Errorf("err = %v want %v", gotErr, wantErr)
85 }
86}
87
88func TestFuncInputTypeError(t *testing.T) {
89 cases := []interface{}{

Callers

nothing calls this directly

Calls 3

HandlerFunction · 0.70
ServeHTTPMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected