Decoder: fix panic on table array behind a pointer (#682)

Fixes #677
This commit is contained in:
Thomas Pelletier
2021-11-24 18:50:04 -05:00
committed by GitHub
parent 1b5a25c0ef
commit 79e78b234c
2 changed files with 39 additions and 1 deletions
+36
View File
@@ -2220,6 +2220,42 @@ func TestIssue666(t *testing.T) {
require.Error(t, err)
}
func TestIssue677(t *testing.T) {
doc := `
[Build]
Name = "publication build"
[[Build.Dependencies]]
Name = "command"
Program = "hugo"
`
type _tomlJob struct {
Dependencies []map[string]interface{}
}
type tomlParser struct {
Build *_tomlJob
}
p := tomlParser{}
err := toml.Unmarshal([]byte(doc), &p)
require.NoError(t, err)
expected := tomlParser{
Build: &_tomlJob{
Dependencies: []map[string]interface{}{
{
"Name": "command",
"Program": "hugo",
},
},
},
}
require.Equal(t, expected, p)
}
//nolint:funlen
func TestUnmarshalDecodeErrors(t *testing.T) {
examples := []struct {