@@ -8,13 +8,14 @@ import (
8
8
)
9
9
10
10
type TestConfig struct {
11
- Foobar string `settingo:"help text for foobar"`
12
- FoobarInt int `settingo:"help text for FoobarInt"`
13
- FoobarBool bool `settingo:"help text for FoobarBool"`
14
- FoobarMap map [string ][]string `settingo:"help text FoobarMap"`
15
- FoobarSlice []string `settingo:"help text for FoobarSlice"`
16
- FoobarSliceSep []string `settingo:"sep=; help text for FoobarSliceSep"`
17
- FooParse string `settingo:"help text for FooParse"`
11
+ Foobar string `settingo:"help text for foobar"`
12
+ FoobarInt int `settingo:"help text for FoobarInt"`
13
+ FoobarBool bool `settingo:"help text for FoobarBool"`
14
+ FoobarMap map [string ][]string `settingo:"help text FoobarMap"`
15
+ FoobarSlice []string `settingo:"help text for FoobarSlice"`
16
+ FoobarSliceSep []string `settingo:"sep=; help text for FoobarSliceSep"`
17
+ FoobarSliceEmptySep []string `settingo:"help text for FoobarSliceEmptySep"`
18
+ FooParse string `settingo:"help text for FooParse"`
18
19
}
19
20
20
21
func Test_struct_types_default (t * testing.T ) {
@@ -33,6 +34,9 @@ func Test_struct_types_default(t *testing.T) {
33
34
os .Setenv ("FOOBARSLICESEP" , "itemA;itemB;itemC" )
34
35
expectedSliceSep := []string {"itemA" , "itemB" , "itemC" }
35
36
37
+ os .Setenv ("FOOBARSLICEEMPTYSEP" , "valA,valB,valC" )
38
+ expectedSliceEmptySep := []string {"valA" , "valB" , "valC" }
39
+
36
40
os .
Setenv (
"FOOPARSE" ,
"postgres://user:[email protected] :5432/mydb" )
37
41
expectedFooParse := "database.example.com"
38
42
@@ -46,13 +50,14 @@ func Test_struct_types_default(t *testing.T) {
46
50
})
47
51
48
52
config := & TestConfig {
49
- Foobar : expected ,
50
- FoobarInt : expectedInt ,
51
- FoobarBool : expectedBool ,
52
- FoobarMap : expectedMap ,
53
- FoobarSlice : expectedSlice ,
54
- FoobarSliceSep : expectedSliceSep ,
55
- FooParse : expectedFooParse ,
53
+ Foobar : expected ,
54
+ FoobarInt : expectedInt ,
55
+ FoobarBool : expectedBool ,
56
+ FoobarMap : expectedMap ,
57
+ FoobarSlice : expectedSlice ,
58
+ FoobarSliceSep : expectedSliceSep ,
59
+ FoobarSliceEmptySep : expectedSliceEmptySep ,
60
+ FooParse : expectedFooParse ,
56
61
}
57
62
58
63
SETTINGS .LoadStruct (config )
@@ -81,6 +86,10 @@ func Test_struct_types_default(t *testing.T) {
81
86
t .Error (config .FoobarSliceSep , " != " , expectedSliceSep )
82
87
}
83
88
89
+ if ! reflect .DeepEqual (config .FoobarSliceEmptySep , expectedSliceEmptySep ) {
90
+ t .Error (config .FoobarSliceEmptySep , " != " , expectedSliceEmptySep )
91
+ }
92
+
84
93
if config .FooParse != expectedFooParse {
85
94
t .Error (config .FooParse , " != " , expectedFooParse )
86
95
}
0 commit comments