File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ func TestCheckConfigStruct(t *testing.T) {
43
43
// A public type with proper tag.
44
44
MyPublicInt string `mapstructure:"int"`
45
45
// A public type that should be ignored.
46
- MyFunc func () error
46
+ MyFunc func () error `mapstructure:"-"`
47
47
// A public type that should be ignored.
48
48
Reader io.Reader
49
49
// private type not tagged.
@@ -176,6 +176,20 @@ func TestCheckConfigStruct(t *testing.T) {
176
176
Slice []string `mapstructure:"test_slice"`
177
177
}{},
178
178
},
179
+ {
180
+ name : "invalid_function_item" ,
181
+ config : struct {
182
+ Function func () `mapstructure:"test_function"`
183
+ }{},
184
+ wantErrMsgSubStr : "config must be able to be marshaled to JSON and YAML, failed to marshal config: json: unsupported type: func()" ,
185
+ },
186
+ {
187
+ name : "valid_ignored_function_item" ,
188
+ config : struct {
189
+ Function func () `mapstructure:"-"`
190
+ Data string `mapstructure:"data"`
191
+ }{},
192
+ },
179
193
}
180
194
181
195
for _ , tt := range tests {
You can’t perform that action at this time.
0 commit comments