-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathconfig_test.go
More file actions
66 lines (59 loc) · 1014 Bytes
/
config_test.go
File metadata and controls
66 lines (59 loc) · 1014 Bytes
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 errors
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSetCfg(t *testing.T) {
tests := []struct {
cfg *Config
want *Config
}{
{
nil,
cfg,
},
{
&Config{
StackDepth: 100,
ErrorConnectionFlag: ":",
},
&Config{
StackDepth: 100,
ErrorConnectionFlag: ":",
},
},
{
&Config{
StackDepth: 100,
},
&Config{
StackDepth: 100,
},
},
}
for i, tt := range tests {
SetCfg(tt.cfg)
got := cfg
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("test %d: got %#v, want %#v", i+1, got, tt.want)
}
}
}
func TestGetCfg(t *testing.T) {
expected := defaultCfg
ResetCfg()
// call GetCfg
c := GetCfg()
// check if returned value is the expected one
assert.Equal(t, expected, c)
}
func TestResetCfg(t *testing.T) {
SetCfg(&Config{
StackDepth: 100,
})
assert.NotEqual(t, defaultCfg, cfg)
ResetCfg()
// check if config was reset to default values
assert.Equal(t, defaultCfg, cfg)
}