MCPcopy Create free account
hub / github.com/keploy/keploy / sprintJSONDiff

Function sprintJSONDiff

pkg/matcher/utils.go:1119–1130  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

1117 * its better to use a generic diff output as the SprintDiff.
1118 */
1119func 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
1132func wrapTextWithAnsi(input string) string {
1133 scanner := bufio.NewScanner(strings.NewReader(input)) // Create a scanner to read the input string line by line.

Callers 2

RenderMethod · 0.85
RenderAppenderMethod · 0.85

Calls 2

isBlankPairFunction · 0.85
expectActualTableFunction · 0.85

Tested by

no test coverage detected