@@ -11,6 +11,11 @@ import (
1111 . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/terminal"
1212)
1313
14+ const (
15+ bold = "\x1b [1m"
16+ reset = "\x1b [0m"
17+ )
18+
1419// Happy path testing
1520func TestPrintTableSimple (t * testing.T ) {
1621 buf := bytes.Buffer {}
@@ -19,7 +24,7 @@ func TestPrintTableSimple(t *testing.T) {
1924 testTable .Print ()
2025 assert .Contains (t , buf .String (), "test2" )
2126 assert .Contains (t , buf .String (), "row1" )
22- assert .Equal (t , "test1 test2\n row1 row2\n " , buf .String ())
27+ assert .Equal (t , bold + "test1 " + reset + bold + " test2 " + reset + " \n row1 row2\n " , buf .String ())
2328}
2429
2530func TestPrintTableJson (t * testing.T ) {
@@ -39,7 +44,7 @@ func TestEmptyHeaderTable(t *testing.T) {
3944 testTable .Add ("row1" , "row2" )
4045 testTable .Print ()
4146 assert .Contains (t , buf .String (), "row1" )
42- assert .Equal (t , "\n row1 row2\n " , buf .String ())
47+ assert .Equal (t , bold + " " + reset + bold + " " + reset + "\n row1 row2\n " , buf .String ())
4348}
4449
4550func TestEmptyHeaderTableJson (t * testing.T ) {
@@ -80,7 +85,7 @@ func TestNotEnoughRowEntires(t *testing.T) {
8085 testTable .Add ("" , "row2" )
8186 testTable .Print ()
8287 assert .Contains (t , buf .String (), "row1" )
83- assert .Equal (t , "col1 col2\n row1\n row2\n " , buf .String ())
88+ assert .Equal (t , bold + "col1 " + reset + bold + " col2 " + reset + " \n row1\n row2\n " , buf .String ())
8489}
8590
8691func TestMoreColThanTerminalWidth (t * testing.T ) {
@@ -90,7 +95,7 @@ func TestMoreColThanTerminalWidth(t *testing.T) {
9095 testTable .Add ("row1" , "row2" )
9196 testTable .Print ()
9297 assert .Contains (t , buf .String (), "row1" )
93- assert .Equal (t , "col1\n row1 row2\n " , buf .String ())
98+ assert .Equal (t , bold + "col1 " + reset + bold + " " + reset + " \n row1 row2\n " , buf .String ())
9499 os .Unsetenv ("TEST_TERMINAL_WIDTH" )
95100}
96101
@@ -101,7 +106,7 @@ func TestWideHeaderNames(t *testing.T) {
101106 testTable .Add ("col1" , "col2" )
102107 testTable .Print ()
103108 assert .Contains (t , buf .String (), "Lorem ipsum dolor sit amet, consectetu" )
104- assert .Equal (t , "Lorem ipsum dolor sit amet, consectetu NAME \n r adipiscing elit, sed do eiusmod temp \n or incididunt u \n col1 col2 \n " , buf .String ())
109+ assert .Equal (t , bold + "ID " + reset + bold + "Name " + reset + " \n ABCDEFG-9b8babbd-f2ed-4371-b817-a839e4130332 row2 \n " , buf .String ())
105110}
106111
107112func TestWidestColumn (t * testing.T ) {
@@ -111,7 +116,7 @@ func TestWidestColumn(t *testing.T) {
111116 testTable .Add (id , "row2" )
112117 testTable .Print ()
113118 assert .Contains (t , buf .String (), id )
114- assert .Equal (t , buf . String (), "ID Name\n ABCDEFG-9b8babbd-f2ed-4371-b817-a839e4130332 row2\n " )
119+ assert .Equal (t , bold + "ID " + reset + bold + " Name " + reset + " \n ABCDEFG-9b8babbd-f2ed-4371-b817-a839e4130332 row2\n ", buf . String () )
115120}
116121
117122func TestMultiWideColumns (t * testing.T ) {
0 commit comments