MCPcopy
hub / github.com/keploy/keploy / sprintDiff

Function sprintDiff

pkg/matcher/utils.go:1093–1110  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1091 * field: body, status...
1092 */
1093func 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.

Callers 2

RenderMethod · 0.85
RenderAppenderMethod · 0.85

Calls 3

isBlankPairFunction · 0.85
expectActualTableFunction · 0.85
CompareMethod · 0.65

Tested by

no test coverage detected