MCPcopy Create free account
hub / github.com/driangle/taskmd / TestTableWriter_HeaderOnly

Function TestTableWriter_HeaderOnly

apps/cli/internal/cli/tablewriter_test.go:150–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func 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}

Callers

nothing calls this directly

Calls 5

AddHeaderMethod · 0.95
AddSeparatorMethod · 0.95
FlushMethod · 0.95
NewTableWriterFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected