common/helpers: fix decoding of strings as slice

We use the previous version of the function from upstream.
This commit is contained in:
Vincent Bernat
2025-02-15 14:25:54 +01:00
parent e08331a286
commit e1672c7f32
2 changed files with 44 additions and 1 deletions

View File

@@ -37,6 +37,28 @@ func TestMapStructureMatchName(t *testing.T) {
}
}
func TestStringToSliceHookFunc(t *testing.T) {
type Configuration struct {
A []string
B []int
}
TestConfigurationDecode(t, ConfigurationDecodeCases{
{
Initial: func() interface{} { return Configuration{} },
Configuration: func() interface{} {
return gin.H{
"a": "blip,blop",
"b": "1,2,3,4",
}
},
Expected: Configuration{
A: []string{"blip", "blop"},
B: []int{1, 2, 3, 4},
},
},
})
}
func TestProtectedDecodeHook(t *testing.T) {
var configuration struct {
A string