* This will return the json diffs in a beautifull way. It will in fact * create a colorized table-based expect-response string and return it. * on the left-side there'll be the expect and on the right the actual * response. Its important to mention the inputs must to be a json. If * the body isn
(json1 []byte, json2 []byte, field string, noise map[string][]string)
| 1117 | * its better to use a generic diff output as the SprintDiff. |
| 1118 | */ |
| 1119 | func sprintJSONDiff(json1 []byte, json2 []byte, field string, noise map[string][]string) (string, error) { |
| 1120 | diff, err := jsonDiff.CompareJSON(json1, json2, noise, false) |
| 1121 | if err != nil { |
| 1122 | return "", err |
| 1123 | } |
| 1124 | // Skip if both sides render blank |
| 1125 | if isBlankPair(diff.Expected, diff.Actual) { |
| 1126 | return "", nil |
| 1127 | } |
| 1128 | result := expectActualTable(diff.Expected, diff.Actual, field, false) |
| 1129 | return result, nil |
| 1130 | } |
| 1131 | |
| 1132 | func wrapTextWithAnsi(input string) string { |
| 1133 | scanner := bufio.NewScanner(strings.NewReader(input)) // Create a scanner to read the input string line by line. |
no test coverage detected