-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlogBufferOptions_test.go
66 lines (62 loc) · 1.41 KB
/
logBufferOptions_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package ginlogrus
import (
"testing"
)
func TestWithBanner(t *testing.T) {
tests := []struct {
name string
want bool
}{
{name: "yes", want: true},
{name: "no", want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opts := defaultLogBufferOptions()
f := WithBanner(tt.want)
f(&opts)
if opts.addBanner != tt.want {
t.Errorf("WithBanner() = %v, want %v", opts.addBanner, tt.want)
}
})
}
}
func TestWithCustomBanner(t *testing.T) {
tests := []struct {
name string
want string
}{
{name: "custom", want: "CustomBanner"},
{name: "default", want: DefaultBanner},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opts := defaultLogBufferOptions()
f := WithCustomBanner(tt.want)
f(&opts)
if opts.banner != tt.want {
t.Errorf("WithBanner() = %v, want %v", opts.addBanner, tt.want)
}
})
}
}
func TestWithHeader(t *testing.T) {
tests := []struct {
name string
wantKey string
wantValue bool
}{
{name: "yes", wantKey: "yes", wantValue: true},
{name: "no", wantKey: "now", wantValue: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opts := defaultLogBufferOptions()
f := WithHeader(tt.wantKey, tt.wantValue)
f(&opts)
if opts.withHeaders[tt.wantKey].(bool) != tt.wantValue {
t.Errorf("WithBanner() = %v, want %v", opts.withHeaders[tt.wantKey].(bool), tt.wantValue)
}
})
}
}