Add regression test for parsing null mounts

This commit is contained in:
Danielle Tomlinson 2019-02-14 13:34:07 +01:00
parent b59ed9d6c9
commit 3f696be06b

View file

@ -41,6 +41,34 @@ func TestConfig_ParseHCL(t *testing.T) {
}
}
func TestConfig_ParseJSON_Regression(t *testing.T) {
cases := []struct {
name string
input string
expected TaskConfig
}{
{
name: "nil values for blocks are safe",
input: `{"Config": {"image": "bash:3", "mounts": null}}`,
expected: TaskConfig{
Image: "bash:3",
Mounts: []DockerMount{},
Devices: []DockerDevice{},
},
},
}
for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
var tc TaskConfig
hclutils.NewConfigParser(taskConfigSpec).ParseJson(t, c.input, &tc)
require.Equal(t, c.expected, tc)
})
}
}
func TestConfig_ParseAllHCL(t *testing.T) {
cfgStr := `
config {