(t *testing.T)
| 54 | } |
| 55 | |
| 56 | func TestDo(t *testing.T) { |
| 57 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 58 | assert.Equal(t, "GET", r.Method) |
| 59 | |
| 60 | fmt.Fprint(w, `{"hello": "world"}`) |
| 61 | })) |
| 62 | defer ts.Close() |
| 63 | |
| 64 | type payload struct { |
| 65 | Hello string `json:"hello"` |
| 66 | } |
| 67 | |
| 68 | client := &Client{} |
| 69 | |
| 70 | req, err := client.NewRequest("GET", ts.URL, nil) |
| 71 | assert.NoError(t, err) |
| 72 | |
| 73 | res, err := client.Do(req) |
| 74 | assert.NoError(t, err) |
| 75 | |
| 76 | var body payload |
| 77 | err = json.NewDecoder(res.Body).Decode(&body) |
| 78 | assert.NoError(t, err) |
| 79 | |
| 80 | assert.Equal(t, "world", body.Hello) |
| 81 | } |
nothing calls this directly
no test coverage detected