(t *testing.T)
| 148 | } |
| 149 | |
| 150 | func TestTableWriter_HeaderOnly(t *testing.T) { |
| 151 | tw := NewTableWriter() |
| 152 | tw.AddHeader([]string{"COL1", "COL2"}) |
| 153 | tw.AddSeparator() |
| 154 | |
| 155 | var buf bytes.Buffer |
| 156 | tw.Flush(&buf) |
| 157 | |
| 158 | lines := strings.Split(strings.TrimRight(buf.String(), "\n"), "\n") |
| 159 | if len(lines) != 2 { |
| 160 | t.Fatalf("expected 2 lines, got %d", len(lines)) |
| 161 | } |
| 162 | if !strings.Contains(lines[0], "COL1") { |
| 163 | t.Error("expected header to contain COL1") |
| 164 | } |
| 165 | if lines[1] != "---- ----" { |
| 166 | t.Errorf("expected separator %q, got %q", "---- ----", lines[1]) |
| 167 | } |
| 168 | } |
nothing calls this directly
no test coverage detected