Pretty-print JSON when inconsistencies arise.
diff --git a/testhelper/http_responses.go b/testhelper/http_responses.go
index bfdfcdf..e6463a5 100644
--- a/testhelper/http_responses.go
+++ b/testhelper/http_responses.go
@@ -69,6 +69,20 @@
}
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.")
}
}