@@ -76,7 +76,7 @@ func TestNewOutputWriterTableWithTabularApproach(t *testing.T) {
7676 NAME STATUS AGE
7777 foo READY 1d
7878 bar Not READY 1d
79- ` ,
79+ ` ,
8080 },
8181
8282 {
@@ -88,20 +88,40 @@ func TestNewOutputWriterTableWithTabularApproach(t *testing.T) {
8888 NAME STATUS AGE
8989 foo READY 1d
9090 bar [31mNot READY[0m 1d
91+ ` ,
92+ },
93+
94+ {
95+ "verify table without headers with 2 columns" ,
96+ []string {},
97+ []interface {}{[]interface {}{"foo" , "READY" }, []interface {}{"bar" , "Not READY" }},
98+ `
99+ foo READY
100+ bar Not READY
101+ ` ,
102+ },
103+ {
104+ "verify table without headers with 1 columns" ,
105+ []string {},
106+ []interface {}{[]interface {}{"row1" }, []interface {}{"row2" }, []interface {}{"row3" }},
107+ `
108+ row1
109+ row2
110+ row3
91111` ,
92112 },
93113 }
94114
95115 for _ , tt := range tests {
96116 t .Run (tt .name , func (t * testing.T ) {
97117 var b bytes.Buffer
98- tab := NewOutputWriter (& b , string (TableOutputType ), "NAME" , "STATUS" , "AGE" )
118+ tab := NewOutputWriter (& b , string (TableOutputType ), tt . header ... )
99119 require .NotNil (t , tab )
100120 for _ , r := range tt .rows {
101121 tab .AddRow (r .([]interface {})... )
102122 }
103123 tab .Render ()
104- assert .Equal (t , strings .TrimSpace (tt .output ), strings . TrimSpace ( b .String () ))
124+ assert .Equal (t , strings .Replace (tt .output , " \n " , "" , 1 ), b .String ())
105125 })
106126 }
107127}
0 commit comments