Add a new e2e test; fix some bugs/usability problems

This commit is contained in:
Daniel Smith
2014-06-13 16:26:38 -07:00
parent a40529b379
commit 5626703634
5 changed files with 103 additions and 27 deletions

View File

@@ -90,14 +90,14 @@ func (client Client) rawRequest(method, path string, requestBody io.Reader, targ
if err != nil {
return nil, err
}
if response.StatusCode != 200 {
return nil, fmt.Errorf("request [%s %s] failed (%d) %s", method, client.makeURL(path), response.StatusCode, response.Status)
}
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return body, err
}
if response.StatusCode != 200 {
return nil, fmt.Errorf("request [%s %s] failed (%d) %s: %s", method, client.makeURL(path), response.StatusCode, response.Status, string(body))
}
if target != nil {
err = json.Unmarshal(body, target)
}