MCPcopy Create free account
hub / github.com/cli/go-gh / Test_tsvTablePrinter_AddHeader

Function Test_tsvTablePrinter_AddHeader

pkg/tableprinter/table_test.go:161–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

159}
160
161func Test_tsvTablePrinter_AddHeader(t *testing.T) {
162 buf := bytes.Buffer{}
163 tp := New(&buf, false, 0)
164
165 // Headers are not output in TSV output.
166 tp.AddHeader([]string{"ONE", "TWO", "THREE"})
167
168 tp.AddField("hello")
169 tp.AddField("beautiful")
170 tp.AddField("people")
171 tp.EndRow()
172 tp.AddField("1")
173 tp.AddField("2")
174 tp.AddField("3")
175 tp.EndRow()
176
177 err := tp.Render()
178 if err != nil {
179 t.Fatalf("unexpected error: %v", err)
180 }
181
182 expected := "hello\tbeautiful\tpeople\n1\t2\t3\n"
183 if buf.String() != expected {
184 t.Errorf("expected: %q, got: %q", expected, buf.String())
185 }
186}

Callers

nothing calls this directly

Calls 6

StringMethod · 0.80
NewFunction · 0.70
AddHeaderMethod · 0.65
AddFieldMethod · 0.65
EndRowMethod · 0.65
RenderMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…