Files
odo/pkg/log/status_test.go
Armel Soro d34fbaed1a 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 98a6554c34.

* Ignore '===' warning header and footer for doc automation tests
2023-09-26 02:53:45 -04:00

65 lines
1.4 KiB
Go

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)
}
})
}
}