-
Notifications
You must be signed in to change notification settings - Fork 9
/
options_test.go
67 lines (63 loc) · 1.44 KB
/
options_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
67
package ginlogrus
import (
"github.com/sirupsen/logrus"
"testing"
)
func TestWithAggregateLogging(t *testing.T) {
tests := []struct {
name string
want bool
}{
{name: "true", want: true},
{name: "false", want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opts := defaultOptions
f := WithAggregateLogging(tt.want)
f(&opts)
if opts.aggregateLogging != tt.want {
t.Errorf("WithAggregateLogging() = %v, want %v", opts.aggregateLogging, tt.want)
}
})
}
}
func TestWithEmptyAggregateEntries(t *testing.T) {
tests := []struct {
name string
want bool
}{
{name: "true", want: true},
{name: "false", want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opts := defaultOptions
f := WithEmptyAggregateEntries(tt.want)
f(&opts)
if opts.emptyAggregateEntries != tt.want {
t.Errorf("WithEmptyAggregateEntries() = %v, want %v", opts.emptyAggregateEntries, tt.want)
}
})
}
}
func TestWithLogLevel(t *testing.T) {
tests := []struct {
name string
want logrus.Level
}{
{name: "info", want: logrus.InfoLevel},
{name: "debug", want: logrus.DebugLevel},
{name: "error", want: logrus.ErrorLevel},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opts := defaultOptions
f := WithLogLevel(tt.want)
f(&opts)
if opts.logLevel != tt.want {
t.Errorf("WithLogLevel() = %v, want %v", opts.aggregateLogging, tt.want)
}
})
}
}