|
|
|
@ -11,9 +11,9 @@ import (
|
|
|
|
|
func TestDo(t *testing.T) {
|
|
|
|
|
svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
}))
|
|
|
|
|
req, err := http.NewRequest(http.MethodGet, svr.URL, nil)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
resp, err := Do("foo", req, func(cli *http.Client) {
|
|
|
|
|
_, err := Get("foo", "tcp://bad request")
|
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
|
resp, err := Get("foo", svr.URL, func(cli *http.Client) {
|
|
|
|
|
cli.Transport = http.DefaultTransport
|
|
|
|
|
})
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
@ -22,9 +22,9 @@ func TestDo(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestDoNotFound(t *testing.T) {
|
|
|
|
|
svr := httptest.NewServer(http.NotFoundHandler())
|
|
|
|
|
req, err := http.NewRequest(http.MethodGet, svr.URL, nil)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
resp, err := Do("foo", req)
|
|
|
|
|
_, err := Post("foo", "tcp://bad request", "application/json", nil)
|
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
|
resp, err := Post("foo", svr.URL, "application/json", nil)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
assert.Equal(t, http.StatusNotFound, resp.StatusCode)
|
|
|
|
|
}
|
|
|
|
|