lotus/lib/tablewriter/tablewiter_test.go

35 lines
668 B
Go
Raw Normal View History

2020-08-04 17:07:17 +00:00
package tablewriter
import (
"os"
"testing"
"github.com/fatih/color"
)
func TestTableWriter(t *testing.T) {
tw := New(Col("C1"), Col("X"), Col("C333"), NewLineCol("Thing"))
tw.Write(map[string]interface{}{
2020-08-04 17:07:31 +00:00
"C1": "234",
2020-08-04 17:07:17 +00:00
"C333": "ou",
})
tw.Write(map[string]interface{}{
2020-08-04 17:07:31 +00:00
"C1": "23uieui4",
"C333": "ou",
"X": color.GreenString("#"),
2020-08-04 17:07:17 +00:00
"Thing": "a very long thing, annoyingly so",
})
tw.Write(map[string]interface{}{
2020-08-04 17:07:31 +00:00
"C1": "ttttttttt",
2020-08-04 17:07:17 +00:00
"C333": "eui",
})
tw.Write(map[string]interface{}{
2020-08-04 17:07:31 +00:00
"C1": "1",
"C333": "2",
2020-08-04 17:07:17 +00:00
"SurpriseColumn": "42",
})
if err := tw.Flush(os.Stdout); err != nil {
t.Fatal(err)
}
}