Skip to content

Commit

Permalink
Fix ansi escape codes for color tests
Browse files Browse the repository at this point in the history
- github.com/fatih/color changed escape codes in 1.16

Co-authored-by: Alex Rocha <alexr1@vmware.com>
Co-authored-by: M. Oleske <moleske@pivotal.io>
  • Loading branch information
moleske and xandroc committed Dec 14, 2023
1 parent 2d3edb7 commit 549598d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions util/ui/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ var _ = Describe("Table", func() {
{"#0", "data1", "data2", "data3"},
},
2)
Expect(out).To(Say(" \x1b\\[1mheader1\x1b\\[0m")) // Makes sure empty values are not bolded
Expect(out).To(Say("\x1b\\[1mheader2\x1b\\[0m"))
Expect(out).To(Say("\x1b\\[1mheader3\x1b\\[0m"))
Expect(out).To(Say(" \u001B\\[1mheader1\u001B\\[22m")) // Makes sure empty values are not bolded
Expect(out).To(Say("\u001B\\[1mheader2\u001B\\[22m"))
Expect(out).To(Say("\u001B\\[1mheader3\u001B\\[22m"))
Expect(out).To(Say("#0 data1 data2 data3"))
})
})
Expand Down
20 changes: 10 additions & 10 deletions util/ui/ui_for_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ var _ = Describe("UI", func() {
{"#2", "crashed", "val1", "val2"},
})

Expect(ui.Out).To(Say("\x1b\\[1mheader1\x1b\\[0m\\s+\x1b\\[1mheader2\x1b\\[0m\\s+\x1b\\[1mheader3\x1b\\[0m")) // Makes sure empty values are not bolded
Expect(ui.Out).To(Say("\u001B\\[1mheader1\u001B\\[22m\\s+\u001B\\[1mheader2\u001B\\[22m\\s+\u001B\\[1mheader3\u001B\\[22m")) // Makes sure empty values are not bolded
Expect(ui.Out).To(Say(`#0\s+starting\s+val1\s+val2`))
Expect(ui.Out).To(Say("#1\\s+\x1b\\[31;1mdown\x1b\\[0m\\s+val1\\s+val2"))
Expect(ui.Out).To(Say("#2\\s+\x1b\\[31;1mcrashed\x1b\\[0m\\s+val1\\s+val2"))
Expect(ui.Out).To(Say("#1\\s+\u001B\\[31;1mdown\u001B\\[0;22m\\s+val1\\s+val2"))
Expect(ui.Out).To(Say("#2\\s+\u001B\\[31;1mcrashed\u001B\\[0;22m\\s+val1\\s+val2"))
})
})

Expand All @@ -65,10 +65,10 @@ var _ = Describe("UI", func() {
{"#2", ui.TranslateText("crashed"), "val1", "val2"},
})

Expect(ui.Out).To(Say("\x1b\\[1mheader1\x1b\\[0m\\s+\x1b\\[1mheader2\x1b\\[0m\\s+\x1b\\[1mheader3\x1b\\[0m")) // Makes sure empty values are not bolded
Expect(ui.Out).To(Say("\u001B\\[1mheader1\u001B\\[22m\\s+\u001B\\[1mheader2\u001B\\[22m\\s+\u001B\\[1mheader3\u001B\\[22m")) // Makes sure empty values are not bolded
Expect(ui.Out).To(Say(`#0\s+%s\s+val1\s+val2`, ui.TranslateText("starting")))
Expect(ui.Out).To(Say("#1\\s+\x1b\\[31;1m%s\x1b\\[0m\\s+val1\\s+val2", ui.TranslateText("down")))
Expect(ui.Out).To(Say("#2\\s+\x1b\\[31;1m%s\x1b\\[0m\\s+val1\\s+val2", ui.TranslateText("crashed")))
Expect(ui.Out).To(Say("#1\\s+\u001B\\[31;1m%s\u001B\\[0;22m\\s+val1\\s+val2", ui.TranslateText("down")))
Expect(ui.Out).To(Say("#2\\s+\u001B\\[31;1m%s\u001B\\[0;22m\\s+val1\\s+val2", ui.TranslateText("crashed")))
})
})
})
Expand Down Expand Up @@ -144,8 +144,8 @@ var _ = Describe("UI", func() {

It("displays a table with requested state and instances in red", func() {
Expect(ui.Out).To(Say("name: dora\n"))
Expect(ui.Out).To(Say("requested state: \x1b\\[31;1mrunning\x1b\\[0m\n"))
Expect(ui.Out).To(Say("instances: \x1b\\[31;1m0/1\x1b\\[0m\n"))
Expect(ui.Out).To(Say("requested state: \u001B\\[31;1mrunning\u001B\\[0;22m\n"))
Expect(ui.Out).To(Say("instances: \u001B\\[31;1m0/1\u001B\\[0;22m\n"))
})
})

Expand All @@ -168,8 +168,8 @@ var _ = Describe("UI", func() {

It("displays a table with requested state and instances in red", func() {
Expect(ui.Out).To(Say("name: dora\n"))
Expect(ui.Out).To(Say("requested state: \x1b\\[31;1m%s\x1b\\[0m\n", ui.TranslateText("running")))
Expect(ui.Out).To(Say("instances: \x1b\\[31;1m0/1\x1b\\[0m\n"))
Expect(ui.Out).To(Say("requested state: \u001B\\[31;1m%s\u001B\\[0;22m\n", ui.TranslateText("running")))
Expect(ui.Out).To(Say("instances: \u001B\\[31;1m0/1\u001B\\[0;22m\n"))
})
})
})
Expand Down
22 changes: 11 additions & 11 deletions util/ui/ui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ var _ = Describe("UI", func() {

It("displays the error to ui.Err and displays FAILED in bold red to ui.Out", func() {
Expect(ui.Err).To(Say("I am an error\n"))
Expect(out).To(Say("\x1b\\[31;1mFAILED\x1b\\[0m\n"))
Expect(out).To(Say("\u001B\\[31;1mFAILED\u001B\\[0;22m\n"))
})

When("the locale is not set to english", func() {
Expand All @@ -110,15 +110,15 @@ var _ = Describe("UI", func() {
It("displays the error text to ui.Err and displays FAILED in bold red to ui.Out", func() {
ui.DisplayError(errors.New("I am a BANANA!"))
Expect(ui.Err).To(Say("I am a BANANA!\n"))
Expect(out).To(Say("\x1b\\[31;1mFAILED\x1b\\[0m\n"))
Expect(out).To(Say("\u001B\\[31;1mFAILED\u001B\\[0;22m\n"))
})
})
})

Describe("DisplayHeader", func() {
It("displays the header colorized and bolded to ui.Out", func() {
ui.DisplayHeader("some-header")
Expect(out).To(Say("\x1b\\[1msome-header\x1b\\[0m"))
Expect(out).To(Say("\u001B\\[1msome-header\u001B\\[22m"))
})

When("the locale is not set to English", func() {
Expand All @@ -134,7 +134,7 @@ var _ = Describe("UI", func() {

It("displays the translated header colorized and bolded to ui.Out", func() {
ui.DisplayHeader("FEATURE FLAGS")
Expect(out).To(Say("\x1b\\[1mINDICATEURS DE FONCTION\x1b\\[0m"))
Expect(out).To(Say("\u001B\\[1mINDICATEURS DE FONCTION\u001B\\[22m"))
})
})
})
Expand All @@ -149,7 +149,7 @@ var _ = Describe("UI", func() {
Describe("DisplayOK", func() {
It("displays 'OK' in green and bold", func() {
ui.DisplayOK()
Expect(out).To(Say("\x1b\\[32;1mOK\x1b\\[0m"))
Expect(out).To(Say("\u001B\\[32;1mOK\u001B\\[0;22m"))
})
})

Expand Down Expand Up @@ -269,7 +269,7 @@ var _ = Describe("UI", func() {
map[string]interface{}{
"SomeMapValue": "map-value",
})
Expect(out).To(Say("template with \x1b\\[1mmap-value\x1b\\[0m"))
Expect(out).To(Say("template with \u001B\\[1mmap-value\u001B\\[22m"))
})
})

Expand All @@ -283,7 +283,7 @@ var _ = Describe("UI", func() {
map[string]interface{}{
"SomeOtherMapValue": "other-map-value",
})
Expect(out).To(Say("template with \x1b\\[1mmap-value\x1b\\[0m and <no value>"))
Expect(out).To(Say("template with \u001B\\[1mmap-value\u001B\\[22m and <no value>"))
})
})

Expand All @@ -304,7 +304,7 @@ var _ = Describe("UI", func() {
map[string]interface{}{
"AppName": "some-app-name",
})
Expect(out).To(Say("L'application \x1b\\[1msome-app-name\x1b\\[0m n'existe pas.\n"))
Expect(out).To(Say("L'application \u001B\\[1msome-app-name\u001B\\[22m n'existe pas.\n"))
})
})
})
Expand All @@ -322,7 +322,7 @@ var _ = Describe("UI", func() {
map[string]interface{}{
"SomeMapValue": "map-value",
})
Expect(out).To(Say("template with \x1b\\[36;1mmap-value\x1b\\[0m"))
Expect(out).To(Say("template with \u001B\\[36;1mmap-value\u001B\\[0;22m"))
})
})

Expand All @@ -336,7 +336,7 @@ var _ = Describe("UI", func() {
map[string]interface{}{
"SomeOtherMapValue": "other-map-value",
})
Expect(out).To(Say("template with \x1b\\[36;1mmap-value\x1b\\[0m and <no value>"))
Expect(out).To(Say("template with \u001B\\[36;1mmap-value\u001B\\[0;22m and <no value>"))
})
})

Expand All @@ -357,7 +357,7 @@ var _ = Describe("UI", func() {
map[string]interface{}{
"AppName": "some-app-name",
})
Expect(out).To(Say("L'application \x1b\\[36;1msome-app-name\x1b\\[0m n'existe pas.\n"))
Expect(out).To(Say("L'application \u001B\\[36;1msome-app-name\u001B\\[0;22m n'existe pas.\n"))
})
})
})
Expand Down

0 comments on commit 549598d

Please sign in to comment.