-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions_test.go
52 lines (40 loc) · 1.02 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
package envparse
import "testing"
func TestSetPrefix(t *testing.T) {
originalPrefix := defaultPrefix
testData := map[string]string{
"ABC": "ABC",
"def": "DEF",
"_smth1_": "SMTH1",
"3app": "3APP",
}
for input, expectedResult := range testData {
SetPrefix(input)
if defaultPrefix != expectedResult {
t.Errorf("input '%s', expected '%s', but got '%s'", input, expectedResult, defaultPrefix)
}
}
defaultPrefix = originalPrefix
}
func TestSetMaxDepth(t *testing.T) {
originalMaxDepth := defaultMaxDepth
testData := map[int]int{
1: 1,
2: 2,
}
for input, expectedResult := range testData {
SetMaxDepth(input)
if defaultMaxDepth != expectedResult {
t.Errorf("input '%d', expected '%d', but got '%d'", input, expectedResult, defaultMaxDepth)
}
}
defaultMaxDepth = originalMaxDepth
}
func TestSetUnsetEnv(t *testing.T) {
originalUnsetEnv := unsetEnv
SetUnsetEnv(true)
if !unsetEnv {
t.Errorf("expected unsetEnv == true, but got unsetEnv == false")
}
unsetEnv = originalUnsetEnv
}