* * Returns a nice diff table where the left is the expect and the right * is the actual. For JSON-based diffs use SprintJSONDiff * field: body, status... */
(expect, actual, field string)
| 1091 | * field: body, status... |
| 1092 | */ |
| 1093 | func sprintDiff(expect, actual, field string) string { |
| 1094 | // Fast skip if identical (including ANSI/whitespace-insensitive no-op) |
| 1095 | if expect == actual || isBlankPair(expect, actual) { |
| 1096 | return "" |
| 1097 | } |
| 1098 | |
| 1099 | diff := jsonDiff.Compare(expect, actual) |
| 1100 | |
| 1101 | // If the computed diff is blank, also skip. |
| 1102 | if isBlankPair(diff.Expected, diff.Actual) { |
| 1103 | return "" |
| 1104 | } |
| 1105 | |
| 1106 | if len(expect) > maxLineLength || len(actual) > maxLineLength { |
| 1107 | return expectActualTable(diff.Expected, diff.Actual, field, false) |
| 1108 | } |
| 1109 | return expectActualTable(diff.Expected, diff.Actual, field, true) |
| 1110 | } |
| 1111 | |
| 1112 | /* This will return the json diffs in a beautifull way. It will in fact |
| 1113 | * create a colorized table-based expect-response string and return it. |
no test coverage detected