hcl2: add failing tests

This commit is contained in:
Mahmood Ali
2021-04-07 16:15:51 -04:00
parent 97f0ed496c
commit b500bdb5cd

View File

@@ -844,3 +844,32 @@ func TestParse_Meta_Alternatives(t *testing.T) {
require.Equal(t, map[string]string{"source": "task"}, asBlock.TaskGroups[0].Tasks[0].Meta)
}
// TestParse_UndefinedVariables asserts that values with undefined variables are left
// intact in the job representation
func TestParse_UndefinedVariables(t *testing.T) {
cases := []string{
"plain",
"foo-${BAR}",
"foo-${attr.network.dev-us-east1-relay-vpc.external-ip.0}",
`${env["BLAH"]}`,
`${mixed-indexing.0[3]["FOO"].5}`,
}
for _, c := range cases {
t.Run(c, func(t *testing.T) {
hcl := `job "example" {
region = "` + c + `"
}`
job, err := ParseWithConfig(&ParseConfig{
Path: "input.hcl",
Body: []byte(hcl),
})
require.NoError(t, err)
require.Equal(t, c, *job.Region)
})
}
}