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
+4 -3
View File
@@ -52,7 +52,8 @@ func TestSetDataErrIfBadHandlerID(t *testing.T) {
defer gock.Off()
gock.New("http://localhost:8080").
Put("/HANDLER_BAD/response/status/code").
Reply(http.StatusNotFound)
Reply(http.StatusNotFound).
BodyString(`{"reason": "Handler ID Not Found"}`)
if err := client.SetData(
"http://localhost:8080",
@@ -61,8 +62,8 @@ func TestSetDataErrIfBadHandlerID(t *testing.T) {
strings.NewReader("200"),
); err == nil {
t.Error("Expected error not present")
} else if err.Error() != "Not Found" {
t.Errorf(`Error mismatch: expected "Not Found", got %q`, err)
} else if err.Error() != "Handler ID Not Found" {
t.Errorf(`Error mismatch: expected "Handler ID Not Found", got %q`, err)
}
if !gock.IsDone() {