internal/http/request.go: replace GetReason() with GetReasonFromBody()

Update tests to inject the required JSON error body with reason.
This commit is contained in:
pancho horrillo
2019-11-19 21:14:20 +01:00
parent e7619238ae
commit 81c677c3be
4 changed files with 15 additions and 7 deletions
+3 -2
View File
@@ -43,12 +43,13 @@ func TestRemoveRouteErrorNonExistent(t *testing.T) {
defer gock.Off()
gock.New("http://localhost:8080").
Delete("/routes/ROUTE_BAD").
Reply(http.StatusNotFound)
Reply(http.StatusNotFound).
BodyString(`{"reason": "Route Not Found"}`)
err := RemoveRoute("http://localhost:8080", "ROUTE_BAD")
if err == nil {
t.Errorf("Error not reported for nonexistent route")
} else if err.Error() != "Not Found" {
} else if err.Error() != "Route Not Found" {
t.Errorf(`Error mismatch: got %q, want "Not Found"`, err)
}