|
@@ -11,6 +11,7 @@ import (
|
|
func TestDo(t *testing.T) {
|
|
func TestDo(t *testing.T) {
|
|
svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
}))
|
|
}))
|
|
|
|
+ defer svr.Close()
|
|
_, err := Get("foo", "tcp://bad request")
|
|
_, err := Get("foo", "tcp://bad request")
|
|
assert.NotNil(t, err)
|
|
assert.NotNil(t, err)
|
|
resp, err := Get("foo", svr.URL)
|
|
resp, err := Get("foo", svr.URL)
|
|
@@ -20,6 +21,7 @@ func TestDo(t *testing.T) {
|
|
|
|
|
|
func TestDoNotFound(t *testing.T) {
|
|
func TestDoNotFound(t *testing.T) {
|
|
svr := httptest.NewServer(http.NotFoundHandler())
|
|
svr := httptest.NewServer(http.NotFoundHandler())
|
|
|
|
+ defer svr.Close()
|
|
_, err := Post("foo", "tcp://bad request", "application/json", nil)
|
|
_, err := Post("foo", "tcp://bad request", "application/json", nil)
|
|
assert.NotNil(t, err)
|
|
assert.NotNil(t, err)
|
|
resp, err := Post("foo", svr.URL, "application/json", nil)
|
|
resp, err := Post("foo", svr.URL, "application/json", nil)
|
|
@@ -29,6 +31,7 @@ func TestDoNotFound(t *testing.T) {
|
|
|
|
|
|
func TestDoMoved(t *testing.T) {
|
|
func TestDoMoved(t *testing.T) {
|
|
svr := httptest.NewServer(http.RedirectHandler("/foo", http.StatusMovedPermanently))
|
|
svr := httptest.NewServer(http.RedirectHandler("/foo", http.StatusMovedPermanently))
|
|
|
|
+ defer svr.Close()
|
|
req, err := http.NewRequest(http.MethodGet, svr.URL, nil)
|
|
req, err := http.NewRequest(http.MethodGet, svr.URL, nil)
|
|
assert.Nil(t, err)
|
|
assert.Nil(t, err)
|
|
_, err = Do("foo", req)
|
|
_, err = Do("foo", req)
|