Fix embedded struct with explicit field name (#773)

Fixes #772
This commit is contained in:
Thomas Pelletier
2022-05-09 18:45:02 +02:00
committed by GitHub
parent ed80712cb4
commit c5ca2c682b
2 changed files with 26 additions and 6 deletions
+20 -1
View File
@@ -554,7 +554,7 @@ wibble = 'wobble'
[foo]
[foo.bar]
huey = 'dewey'
huey = 'dewey'
`,
gen: func() test {
m := map[string]interface{}{}
@@ -2380,6 +2380,25 @@ func TestIssue714(t *testing.T) {
require.Error(t, err)
}
func TestIssue772(t *testing.T) {
type FileHandling struct {
FilePattern string `toml:"pattern"`
}
type Config struct {
FileHandling `toml:"filehandling"`
}
var defaultConfigFile = []byte(`
[filehandling]
pattern = "reach-masterdev-"`)
config := Config{}
err := toml.Unmarshal(defaultConfigFile, &config)
require.NoError(t, err)
require.Equal(t, "reach-masterdev-", config.FileHandling.FilePattern)
}
func TestUnmarshalDecodeErrors(t *testing.T) {
examples := []struct {
desc string