(t *testing.T)
| 79 | } |
| 80 | |
| 81 | func Test_ttyTablePrinter_AddHeader(t *testing.T) { |
| 82 | buf := bytes.Buffer{} |
| 83 | tp := New(&buf, true, 80) |
| 84 | |
| 85 | tp.AddHeader([]string{"ONE", "TWO", "THREE"}, WithColor(func(s string) string { |
| 86 | return fmt.Sprintf("\x1b[4m%s\x1b[m", s) |
| 87 | })) |
| 88 | // Subsequent calls to AddHeader are ignored. |
| 89 | tp.AddHeader([]string{"SHOULD", "NOT", "EXIST"}) |
| 90 | |
| 91 | tp.AddField("hello") |
| 92 | tp.AddField("beautiful") |
| 93 | tp.AddField("people") |
| 94 | tp.EndRow() |
| 95 | |
| 96 | err := tp.Render() |
| 97 | if err != nil { |
| 98 | t.Fatalf("unexpected error: %v", err) |
| 99 | } |
| 100 | |
| 101 | expected := heredoc.Docf(` |
| 102 | %[1]s[4mONE %[1]s[m %[1]s[4mTWO %[1]s[m %[1]s[4mTHREE%[1]s[m |
| 103 | hello beautiful people |
| 104 | `, "\x1b") |
| 105 | if buf.String() != expected { |
| 106 | t.Errorf("expected: %q, got: %q", expected, buf.String()) |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | func Test_ttyTablePrinter_WithPadding(t *testing.T) { |
| 111 | buf := bytes.Buffer{} |
nothing calls this directly
no test coverage detected
searching dependent graphs…