MCPcopy
hub / github.com/keploy/keploy / printFieldDiffTable

Function printFieldDiffTable

pkg/service/replay/utils.go:1066–1092  ·  view source on GitHub ↗

printFieldDiffTable renders the compact FIELD | EXPECTED | RECEIVED table — the fallback when whole-request renders aren't available. Reads the noise-vocabulary MockFieldDiff (Path/Kind/Expected/Actual).

(fieldDiffs []models.MockFieldDiff)

Source from the content-addressed store, hash-verified

1064// the fallback when whole-request renders aren't available. Reads the
1065// noise-vocabulary MockFieldDiff (Path/Kind/Expected/Actual).
1066func printFieldDiffTable(fieldDiffs []models.MockFieldDiff) {
1067 colWidths := tw.NewMapper[int, int]().Set(0, 24).Set(1, 40).Set(2, 40)
1068 table := tablewriter.NewTable(os.Stdout,
1069 tablewriter.WithRendition(tw.Rendition{
1070 Settings: tw.Settings{Separators: tw.Separators{BetweenRows: tw.On}},
1071 }),
1072 tablewriter.WithRowAutoWrap(1),
1073 tablewriter.WithHeaderAlignment(tw.AlignCenter),
1074 tablewriter.WithRowAlignment(tw.AlignLeft),
1075 tablewriter.WithMaxWidth(120),
1076 tablewriter.WithColumnWidths(colWidths),
1077 )
1078 table.Header([]string{"FIELD", "EXPECTED (MOCK)", "RECEIVED (REQUEST)"})
1079 for _, d := range fieldDiffs {
1080 exp, rec := d.Expected, d.Actual
1081 switch d.Kind {
1082 case models.DiffKindMissingInLive:
1083 rec = "(missing)"
1084 case models.DiffKindMissingInMock:
1085 exp = "(not recorded)"
1086 case models.DiffKindTypeChanged:
1087 exp, rec = "type "+d.Expected, "type "+d.Actual
1088 }
1089 table.Append([]string{d.Path, exp, rec})
1090 }
1091 table.Render()
1092}

Callers 1

printMismatchReportFunction · 0.85

Calls 2

SetMethod · 0.45
RenderMethod · 0.45

Tested by

no test coverage detected