test/helpers: include error return when route fails

This commit is contained in:
Lars Karlitski 2020-04-23 14:04:54 +02:00 committed by Tom Gundersen
parent 5c019cd092
commit cf53e6a9e2

View file

@ -108,11 +108,11 @@ func TestRoute(t *testing.T, api API, external bool, method, path, body string,
t.Skip("This test is for internal testing only")
}
assert.Equalf(t, expectedStatus, resp.StatusCode, "SendHTTP failed for path %s", path)
replyJSON, err := ioutil.ReadAll(resp.Body)
require.NoErrorf(t, err, "%s: could not read response body", path)
assert.Equalf(t, expectedStatus, resp.StatusCode, "SendHTTP failed for path %s: %v", path, string(replyJSON))
if expectedJSON == "" {
require.Lenf(t, replyJSON, 0, "%s: expected no response body, but got:\n%s", path, replyJSON)
}