MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / TestError

Function TestError

pkg/httpcli/httpcli_test.go:695–730  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

693}
694
695func TestError(t *testing.T) {
696 req := New()
697 req.SetParam("foo", "bar")
698 req.SetParam("foo3", make(chan string))
699 req.SetParams(map[string]interface{}{"foo2": "bar2"})
700 req.SetBody("foo")
701 req.SetTimeout(time.Second * 10)
702 req.CustomRequest(func(req *http.Request, data *bytes.Buffer) {
703 fmt.Println("customRequest")
704 })
705 req.SetURL("http://127.0.0.1:0")
706
707 resp, err := req.pull()
708 assert.Error(t, err)
709
710 req.method = http.MethodPost
711 resp, err = req.push()
712 assert.Error(t, err)
713
714 _, err = resp.ReadBody()
715 assert.Error(t, err)
716
717 err = resp.BindJSON(nil)
718 assert.Error(t, err)
719
720 err = notOKErr(resp)
721 assert.Error(t, err)
722
723 err = do(http.MethodPost, nil, "", nil, nil, nil, 0)
724 assert.Error(t, err)
725 err = do(http.MethodPost, &StdResult{}, "http://127.0.0.1:0", nil, KV{"foo": "bar"}, nil, 0)
726 assert.Error(t, err)
727
728 err = gDo(http.MethodGet, nil, "http://127.0.0.1:0", nil, nil, 0)
729 assert.Error(t, err)
730}

Callers

nothing calls this directly

Calls 15

gDoFunction · 0.85
SetParamMethod · 0.80
SetParamsMethod · 0.80
SetBodyMethod · 0.80
SetTimeoutMethod · 0.80
CustomRequestMethod · 0.80
PrintlnMethod · 0.80
SetURLMethod · 0.80
pullMethod · 0.80
pushMethod · 0.80
ReadBodyMethod · 0.80
BindJSONMethod · 0.80

Tested by

no test coverage detected