@@ -11,6 +11,11 @@ import (
11
11
. "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/terminal"
12
12
)
13
13
14
+ const (
15
+ bold = "\x1b [1m"
16
+ reset = "\x1b [0m"
17
+ )
18
+
14
19
// Happy path testing
15
20
func TestPrintTableSimple (t * testing.T ) {
16
21
buf := bytes.Buffer {}
@@ -19,7 +24,7 @@ func TestPrintTableSimple(t *testing.T) {
19
24
testTable .Print ()
20
25
assert .Contains (t , buf .String (), "test2" )
21
26
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 ())
23
28
}
24
29
25
30
func TestPrintTableJson (t * testing.T ) {
@@ -39,7 +44,7 @@ func TestEmptyHeaderTable(t *testing.T) {
39
44
testTable .Add ("row1" , "row2" )
40
45
testTable .Print ()
41
46
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 ())
43
48
}
44
49
45
50
func TestEmptyHeaderTableJson (t * testing.T ) {
@@ -80,7 +85,7 @@ func TestNotEnoughRowEntires(t *testing.T) {
80
85
testTable .Add ("" , "row2" )
81
86
testTable .Print ()
82
87
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 ())
84
89
}
85
90
86
91
func TestMoreColThanTerminalWidth (t * testing.T ) {
@@ -90,7 +95,7 @@ func TestMoreColThanTerminalWidth(t *testing.T) {
90
95
testTable .Add ("row1" , "row2" )
91
96
testTable .Print ()
92
97
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 ())
94
99
os .Unsetenv ("TEST_TERMINAL_WIDTH" )
95
100
}
96
101
@@ -101,7 +106,7 @@ func TestWideHeaderNames(t *testing.T) {
101
106
testTable .Add ("col1" , "col2" )
102
107
testTable .Print ()
103
108
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 ())
105
110
}
106
111
107
112
func TestWidestColumn (t * testing.T ) {
@@ -111,7 +116,7 @@ func TestWidestColumn(t *testing.T) {
111
116
testTable .Add (id , "row2" )
112
117
testTable .Print ()
113
118
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 () )
115
120
}
116
121
117
122
func TestMultiWideColumns (t * testing.T ) {
0 commit comments