fix: return an error instead of panic.
This commit is contained in:
parent
86261f2b0a
commit
230cd28ac9
2 changed files with 59 additions and 15 deletions
|
@ -538,3 +538,27 @@ func Test_decodeRawToNode(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_decodeRawToNode_errors(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
data map[string]interface{}
|
||||
}{
|
||||
{
|
||||
desc: "invalid type",
|
||||
data: map[string]interface{}{
|
||||
"foo": struct{}{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
test := test
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := decodeRawToNode(test.data, parser.DefaultRootName)
|
||||
require.Error(t, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue