From b64624c3d7e90b388100263ed8fe0df8caacbe39 Mon Sep 17 00:00:00 2001 From: "M. Oleske" Date: Thu, 14 Dec 2023 15:28:47 -0800 Subject: [PATCH] Fix ansi escape codes for color tests - github.com/fatih/color changed escape codes in 1.16 Co-authored-by: Alex Rocha Co-authored-by: M. Oleske --- util/ui/table_test.go | 6 +++--- util/ui/ui_for_app_test.go | 20 ++++++++++---------- util/ui/ui_test.go | 30 +++++++++++++++--------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/util/ui/table_test.go b/util/ui/table_test.go index cb700236d23..3156f797d86 100644 --- a/util/ui/table_test.go +++ b/util/ui/table_test.go @@ -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")) }) }) diff --git a/util/ui/ui_for_app_test.go b/util/ui/ui_for_app_test.go index daf7f7ed2cc..f6805659a8d 100644 --- a/util/ui/ui_for_app_test.go +++ b/util/ui/ui_for_app_test.go @@ -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")) }) }) @@ -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"))) }) }) }) @@ -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")) }) }) @@ -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")) }) }) }) diff --git a/util/ui/ui_test.go b/util/ui/ui_test.go index 822f43a7c6d..957ec5f70d5 100644 --- a/util/ui/ui_test.go +++ b/util/ui/ui_test.go @@ -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() { @@ -110,7 +110,7 @@ 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")) }) }) }) @@ -118,7 +118,7 @@ var _ = Describe("UI", func() { 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() { @@ -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")) }) }) }) @@ -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")) }) }) @@ -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")) }) }) @@ -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 ")) + Expect(out).To(Say("template with \u001B\\[1mmap-value\u001B\\[22m and ")) }) }) @@ -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")) }) }) }) @@ -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")) }) }) @@ -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 ")) + Expect(out).To(Say("template with \u001B\\[36;1mmap-value\u001B\\[0;22m and ")) }) }) @@ -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")) }) }) }) @@ -365,11 +365,11 @@ var _ = Describe("UI", func() { Describe("DisplayDiffAddition", func() { It("displays a green indented line with a +", func() { ui.DisplayDiffAddition("added", 3, false) - Expect(out).To(Say(`\x1b\[32m\+ added\x1b\[0m`)) + Expect(out).To(Say("\u001B\\[32m\\+\\s+added\u001B\\[0m")) }) It("displays a hyphen when the addHyphen is true", func() { ui.DisplayDiffAddition("added", 3, true) - Expect(out).To(Say(`\x1b\[32m\+ - added\x1b\[0m`)) + Expect(out).To(Say("\u001B\\[32m\\+\\s+\\- added\u001B\\[0m")) }) }) @@ -377,11 +377,11 @@ var _ = Describe("UI", func() { Describe("DisplayDiffRemoval", func() { It("displays a red indented line with a -", func() { ui.DisplayDiffRemoval("removed", 3, false) - Expect(out).To(Say(`\x1b\[31m\- removed\x1b\[0m`)) + Expect(out).To(Say("\u001B\\[31m\\-\\s+removed\u001B\\[0m")) }) It("displays a a hyphen when addHyphen is true", func() { ui.DisplayDiffRemoval("removed", 3, true) - Expect(out).To(Say(`\x1b\[31m\- - removed\x1b\[0m`)) + Expect(out).To(Say("\u001B\\[31m\\-\\s+\\- removed\u001B\\[0m")) }) })