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)
| 1064 | // the fallback when whole-request renders aren't available. Reads the |
| 1065 | // noise-vocabulary MockFieldDiff (Path/Kind/Expected/Actual). |
| 1066 | func 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 | } |
no test coverage detected