...
1 package log
2
3 import (
4 "testing"
5
6 "github.com/google/go-cmp/cmp"
7 )
8
9 func Test_wrapWarningMessage(t *testing.T) {
10 type args struct {
11 fullMessage string
12 }
13 tests := []struct {
14 name string
15 args args
16 want string
17 }{
18 {
19 name: "empty message",
20 args: args{
21 fullMessage: "",
22 },
23 want: "",
24 },
25 {
26 name: "single-line message",
27 args: args{
28 fullMessage: "Lorem Ipsum Dolor Sit Amet",
29 },
30 want: `==========================
31 Lorem Ipsum Dolor Sit Amet
32 ==========================`,
33 },
34 {
35 name: "multi-line message",
36 args: args{
37 fullMessage: `
38 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
39 Aenean vel faucibus ex.
40 Nulla in magna sem.
41 Vivamus condimentum ultricies erat, in ullamcorper risus tempor nec.
42 Nam sed risus blandit,
43 `,
44 },
45 want: `====================================================================
46
47 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
48 Aenean vel faucibus ex.
49 Nulla in magna sem.
50 Vivamus condimentum ultricies erat, in ullamcorper risus tempor nec.
51 Nam sed risus blandit,
52
53 ====================================================================`,
54 },
55 }
56 for _, tt := range tests {
57 t.Run(tt.name, func(t *testing.T) {
58 got := wrapWarningMessage(tt.args.fullMessage)
59 if diff := cmp.Diff(tt.want, got); diff != "" {
60 t.Errorf("wrapWarningMessage() mismatch (-want +got):\n%s", diff)
61 }
62 })
63 }
64 }
65
View as plain text