(t *testing.T)
| 189 | } |
| 190 | |
| 191 | func TestPrintResult(t *testing.T) { |
| 192 | t.Run("DisplayModeTable", func(t *testing.T) { |
| 193 | out := &bytes.Buffer{} |
| 194 | result := &Result{ |
| 195 | ColumnNames: []string{"foo", "bar"}, |
| 196 | Rows: []Row{ |
| 197 | {[]string{"1", "2"}}, |
| 198 | {[]string{"3", "4"}}, |
| 199 | }, |
| 200 | IsMutation: false, |
| 201 | } |
| 202 | printResult(out, result, DisplayModeTable, false, false) |
| 203 | |
| 204 | expected := strings.TrimPrefix(` |
| 205 | +-----+-----+ |
| 206 | | foo | bar | |
| 207 | +-----+-----+ |
| 208 | | 1 | 2 | |
| 209 | | 3 | 4 | |
| 210 | +-----+-----+ |
| 211 | `, "\n") |
| 212 | |
| 213 | got := out.String() |
| 214 | if got != expected { |
| 215 | t.Errorf("invalid print: expected = %s, but got = %s", expected, got) |
| 216 | } |
| 217 | }) |
| 218 | |
| 219 | t.Run("DisplayModeVertical", func(t *testing.T) { |
| 220 | out := &bytes.Buffer{} |
| 221 | result := &Result{ |
| 222 | ColumnNames: []string{"foo", "bar"}, |
| 223 | Rows: []Row{ |
| 224 | {[]string{"1", "2"}}, |
| 225 | {[]string{"3", "4"}}, |
| 226 | }, |
| 227 | IsMutation: false, |
| 228 | } |
| 229 | printResult(out, result, DisplayModeVertical, false, false) |
| 230 | |
| 231 | expected := strings.TrimPrefix(` |
| 232 | *************************** 1. row *************************** |
| 233 | foo: 1 |
| 234 | bar: 2 |
| 235 | *************************** 2. row *************************** |
| 236 | foo: 3 |
| 237 | bar: 4 |
| 238 | `, "\n") |
| 239 | |
| 240 | got := out.String() |
| 241 | if got != expected { |
| 242 | t.Errorf("invalid print: expected = %s, but got = %s", expected, got) |
| 243 | } |
| 244 | }) |
| 245 | |
| 246 | t.Run("DisplayModeTab", func(t *testing.T) { |
| 247 | out := &bytes.Buffer{} |
| 248 | result := &Result{ |
nothing calls this directly
no test coverage detected