*JSONEquals() testhelper methods.
These are helpful for testing .ToXyzMap() methods, in particular.
diff --git a/testhelper/http_responses.go b/testhelper/http_responses.go
index 481a833..e1f1f9a 100644
--- a/testhelper/http_responses.go
+++ b/testhelper/http_responses.go
@@ -81,33 +81,11 @@
t.Errorf("Unable to read request body: %v", err)
}
- var expectedJSON interface{}
- err = json.Unmarshal([]byte(expected), &expectedJSON)
- if err != nil {
- t.Errorf("Unable to parse expected value as JSON: %v", err)
- }
-
var actualJSON interface{}
err = json.Unmarshal(b, &actualJSON)
if err != nil {
t.Errorf("Unable to parse request body as JSON: %v", err)
}
- if !reflect.DeepEqual(expectedJSON, actualJSON) {
- prettyExpected, err := json.MarshalIndent(expectedJSON, "", " ")
- if err != nil {
- t.Logf("Unable to pretty-print expected JSON: %v\n%s", err, expected)
- } else {
- t.Logf("Expected JSON:\n%s", prettyExpected)
- }
-
- prettyActual, err := json.MarshalIndent(actualJSON, "", " ")
- if err != nil {
- t.Logf("Unable to pretty-print actual JSON: %v\n%s", err, b)
- } else {
- t.Logf("Actual JSON:\n%s", prettyActual)
- }
-
- t.Errorf("Response body did not contain the correct JSON.")
- }
+ CheckJSONEquals(t, expected, actualJSON)
}