-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
56 lines (51 loc) · 1.03 KB
/
config_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
package glog
import (
"testing"
)
func TestConfig_Build(t *testing.T) {
cfg := NewDefaultConfig()
logger, err := cfg.Build()
if err != nil {
t.Errorf("Expected no error, but got %v", err)
}
if logger == nil {
t.Error("Expected logger to be created, but got nil")
}
stackLevel := LevelError
cfg = &Config{
Level: LevelInfo,
AddCaller: true,
StackLevel: &stackLevel,
Sampling: &SamplingConfig{
Initial: 50,
Thereafter: 50,
},
Core: CoreConfig{
Encoding: "json",
},
}
logger, err = cfg.Build()
if err != nil {
t.Errorf("Expected no error, but got %v", err)
}
if logger == nil {
t.Error("Expected logger to be created, but got nil")
}
}
func TestConfig_buildOptions(t *testing.T) {
cfg := &Config{}
opts := cfg.buildOptions()
if len(opts) != 0 {
t.Error("Expected no options, but got", opts)
}
cfg = &Config{
InitialFields: map[string]any{
"key1": "value1",
"key2": "value2",
},
}
opts = cfg.buildOptions()
if len(opts) != 1 {
t.Error("Expected one option, but got", opts)
}
}