Skip to content

Commit da13361

Browse files
authored
Merge pull request #461 from IBM-Cloud/fix/mcp-enable-test
test: updated PluginContext mock
2 parents a3691ed + 38a78cf commit da13361

File tree

3 files changed

+77
-6
lines changed

3 files changed

+77
-6
lines changed

bluemix/terminal/table.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func (t *PrintableTable) Print() {
127127
tbl.Style().Options.SeparateHeader = false
128128
tbl.Style().Options.SeparateRows = false
129129
tbl.Style().Format.Header = text.FormatDefault
130+
tbl.Style().Color.Header = text.Colors{text.Bold}
130131

131132
headerRow, rows := t.createPrettyRowsAndHeaders()
132133
columnConfig := t.createColumnConfigs()

bluemix/terminal/table_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
1520
func 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\nrow1 row2\n", buf.String())
27+
assert.Equal(t, bold+"test1 "+reset+bold+"test2 "+reset+"\nrow1 row2\n", buf.String())
2328
}
2429

2530
func 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, "\nrow1 row2\n", buf.String())
47+
assert.Equal(t, bold+" "+reset+bold+" "+reset+"\nrow1 row2\n", buf.String())
4348
}
4449

4550
func 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\nrow1\n row2\n", buf.String())
88+
assert.Equal(t, bold+"col1 "+reset+bold+"col2 "+reset+"\nrow1\n row2\n", buf.String())
8489
}
8590

8691
func 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\nrow1 row2\n", buf.String())
98+
assert.Equal(t, bold+"col1 "+reset+bold+" "+reset+"\nrow1 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\nr adipiscing elit, sed do eiusmod temp\nor incididunt u\ncol1 col2\n", buf.String())
109+
assert.Equal(t, bold+"ID "+reset+bold+"Name "+reset+"\nABCDEFG-9b8babbd-f2ed-4371-b817-a839e4130332 row2\n", buf.String())
105110
}
106111

107112
func 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\nABCDEFG-9b8babbd-f2ed-4371-b817-a839e4130332 row2\n")
119+
assert.Equal(t, bold+"ID "+reset+bold+"Name "+reset+"\nABCDEFG-9b8babbd-f2ed-4371-b817-a839e4130332 row2\n", buf.String())
115120
}
116121

117122
func TestMultiWideColumns(t *testing.T) {

plugin/pluginfakes/fake_plugin_context.go

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)