-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make warning messages more visible (#7097)
* Wrap warning messages to make them more visible For example, instead of displaying: ``` ⚠ You are using "default" project, odo may not work as expected in the default project. ``` We are now displaying: ``` ======================================================================================== ⚠ You are using "default" project, odo may not work as expected in the default project. ======================================================================================== ``` * Display warning message about default project/namespace in a single block * Add unit test * Fix sample outputs for doc automation tests * Revert "Fix sample outputs for doc automation tests" This reverts commit 98a6554. * Ignore '===' warning header and footer for doc automation tests
- Loading branch information
Showing
4 changed files
with
96 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package log | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
func Test_wrapWarningMessage(t *testing.T) { | ||
type args struct { | ||
fullMessage string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
}{ | ||
{ | ||
name: "empty message", | ||
args: args{ | ||
fullMessage: "", | ||
}, | ||
want: "", | ||
}, | ||
{ | ||
name: "single-line message", | ||
args: args{ | ||
fullMessage: "Lorem Ipsum Dolor Sit Amet", | ||
}, | ||
want: `========================== | ||
Lorem Ipsum Dolor Sit Amet | ||
==========================`, | ||
}, | ||
{ | ||
name: "multi-line message", | ||
args: args{ | ||
fullMessage: ` | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
Aenean vel faucibus ex. | ||
Nulla in magna sem. | ||
Vivamus condimentum ultricies erat, in ullamcorper risus tempor nec. | ||
Nam sed risus blandit, | ||
`, | ||
}, | ||
want: `==================================================================== | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
Aenean vel faucibus ex. | ||
Nulla in magna sem. | ||
Vivamus condimentum ultricies erat, in ullamcorper risus tempor nec. | ||
Nam sed risus blandit, | ||
====================================================================`, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := wrapWarningMessage(tt.args.fullMessage) | ||
if diff := cmp.Diff(tt.want, got); diff != "" { | ||
t.Errorf("wrapWarningMessage() mismatch (-want +got):\n%s", diff) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters