From e56dd1337ecfa2781051adb49aa14518d25dce11 Mon Sep 17 00:00:00 2001 From: aurc <54873456+aurc@users.noreply.github.com> Date: Mon, 20 Jun 2022 14:20:30 +1000 Subject: [PATCH] Fixed unit tests --- config-sample/gcp.yaml | 14 +++++++++++++- internal/char/canvas_test.go | 16 ++++++++-------- internal/config/log_config_test.go | 27 ++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/config-sample/gcp.yaml b/config-sample/gcp.yaml index 6776f70..32c1304 100644 --- a/config-sample/gcp.yaml +++ b/config-sample/gcp.yaml @@ -2,6 +2,9 @@ keys: - name: timestamp type: datetime layout: 2006-01-02T15:04:05-0700 + color: + foreground: purple + background: black - name: severity type: string color: @@ -26,7 +29,16 @@ keys: background: black - name: resource/labels/container_name type: string + color: + foreground: darkgreen + background: black - name: trace type: string + color: + foreground: white + background: black - name: jsonPayload/message - type: string \ No newline at end of file + type: string + color: + foreground: white + background: black \ No newline at end of file diff --git a/internal/char/canvas_test.go b/internal/char/canvas_test.go index 7f3c269..12f7a18 100644 --- a/internal/char/canvas_test.go +++ b/internal/char/canvas_test.go @@ -131,14 +131,14 @@ func TestCanvas_BlankCanvasAsString(t *testing.T) { name: "Test l`oGGo", words: LoggoLogo, wants: `╔╦╦╦╦╦╦╦╦▓▓░╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╗ -╠▓▓▓░╬╬╬╬▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓░╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ -╠╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬▓▓▓░╬╬╬╬╬▓▓▓░╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ -╠╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ -╠╬╬▓▓░╬╬╬╬╬╬▓▓▓▓▓░╬╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬╬▓▓▓▓▓░╬╬╬╬╬╬╣ -╠╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╣ -╠╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬╬▓▓▓▓▓░╬▓▓▓▓▓░╬╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬▓▓░╬╬╬╣ -╠╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬╬╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬▓▓░╬╬╬╣ -╠╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╬╬▓▓▓░╬╬╬▓▓▓░╬╬╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╣ +╠▓▓▓░╬╬╬╬▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓░╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ +╠╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓░╬╬╬╬▓▓░╬╬╬╬╬╬╬▓▓░╬╬╬╬▓▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ +╠╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ +╠╬╬▓▓░╬╬╬╬╬╬▓▓▓▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓░╬╬╬╬╬╬╣ +╠╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╣ +╠╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬▓▓░╬▓▓▓▓▓░╬╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬╬▓▓▓▓▓░╬▓▓░╬╬╬╬╬╬▓▓░╬╬╬╣ +╠╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬▓▓░╬╬▓▓░╬╬╬╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬╬╬╬▓▓░╬╬▓▓░╬╬╬╬╬╬▓▓░╬╬╬╣ +╠╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬▓▓▓░╬╬╬╬╬╬▓▓░╬╬╬╬╬▓▓░╬╬╬╬╬╬▓▓▓░╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╣ ╠╬╬╬▓▓▓░╬╬╬╬▓▓▓▓▓░╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓░╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓░╬╬╬╬╬╬╬╬▓▓▓▓▓░╬╬╬╬╬╬╣ ╚╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╝`, }, diff --git a/internal/config/log_config_test.go b/internal/config/log_config_test.go index 1085da2..5855770 100644 --- a/internal/config/log_config_test.go +++ b/internal/config/log_config_test.go @@ -61,6 +61,7 @@ func TestMakeConfig(t *testing.T) { } for _, test := range tests { t.Run(test.name, func(t *testing.T) { + test.wants.LastSavedName = test.givenFile c, err := MakeConfig(test.givenFile) if test.wantsError { assert.Error(t, err) @@ -121,6 +122,10 @@ var defConfig = Config{ Name: "timestamp", Type: TypeDateTime, Layout: "2006-01-02T15:04:05-0700", + Color: Color{ + Foreground: "purple", + Background: "black", + }, }, { Name: "severity", @@ -140,22 +145,22 @@ var defConfig = Config{ { MatchValue: "INFO", Color: Color{ - Foreground: "white", + Foreground: "green", Background: "black", }, }, { MatchValue: "WARN", Color: Color{ - Foreground: "red", - Background: "yellow", + Foreground: "yellow", + Background: "black", }, }, { MatchValue: "DEBUG", Color: Color{ - Foreground: "white", - Background: "blue", + Foreground: "blue", + Background: "black", }, }, }, @@ -163,14 +168,26 @@ var defConfig = Config{ { Name: "resource/labels/container_name", Type: TypeString, + Color: Color{ + Foreground: "darkgreen", + Background: "black", + }, }, { Name: "trace", Type: TypeString, + Color: Color{ + Foreground: "white", + Background: "black", + }, }, { Name: "jsonPayload/message", Type: TypeString, + Color: Color{ + Foreground: "white", + Background: "black", + }, }, }, }