From b1967553620c302d528a2245fb4fb6da4cad50f7 Mon Sep 17 00:00:00 2001 From: lotusirous <5105237+lotusirous@users.noreply.github.com> Date: Sat, 29 Oct 2022 10:09:33 +0700 Subject: [PATCH] Fix printer test --- printer.go | 6 +++--- printer_test.go | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/printer.go b/printer.go index defeea1..2af43d7 100644 --- a/printer.go +++ b/printer.go @@ -13,8 +13,8 @@ type RowRenderer interface { AddRow(field, value string) // AddRowMap appends the row by map input. AddRowMap(values map[string]string) - // Render the rows. - Render() + // RenderTo the rows. + RenderTo(w io.Writer) } // NewRowRender creates the printer. @@ -49,7 +49,7 @@ func (p *pw) AddRowMap(values map[string]string) { } // Render the rows to output -func (p *pw) Render() { +func (p *pw) RenderTo(w io.Writer) { for _, l := range p.rows { fmt.Fprintf(p.w, "%s: %s\n", strings.ToUpper(l[0]), l[1]) } diff --git a/printer_test.go b/printer_test.go index ac7113d..1c01cea 100644 --- a/printer_test.go +++ b/printer_test.go @@ -8,14 +8,13 @@ import ( func TestRowPrinter(t *testing.T) { buf := new(bytes.Buffer) pw := &pw{buf, make([][]string, 0)} - pw.AddRow("foo", "bar") - pw.Render() + pw.AddRow("FILE", "bar") + pw.RenderTo(buf) got := buf.String() - want := "FOO: bar\n" + want := "FILE: bar\n" if got != want { t.Errorf("Got: %s - want: %s", buf, want) } - }