Encode: support comment on array tables (#776)

Fixes #774
This commit is contained in:
Thomas Pelletier
2022-05-10 15:17:36 +02:00
committed by GitHub
parent b2e0231cc9
commit 627dade0c7
2 changed files with 28 additions and 1 deletions
+24
View File
@@ -2399,6 +2399,30 @@ func TestIssue772(t *testing.T) {
require.Equal(t, "reach-masterdev-", config.FileHandling.FilePattern)
}
func TestIssue774(t *testing.T) {
type ScpData struct {
Host string `json:"host"`
}
type GenConfig struct {
SCP []ScpData `toml:"scp" comment:"Array of Secure Copy Configurations"`
}
c := &GenConfig{}
c.SCP = []ScpData{{Host: "main.domain.com"}}
b, err := toml.Marshal(c)
require.NoError(t, err)
expected := `# Array of Secure Copy Configurations
[[scp]]
Host = 'main.domain.com'
`
require.Equal(t, expected, string(b))
}
func TestUnmarshalDecodeErrors(t *testing.T) {
examples := []struct {
desc string