config: test covering escaped quotes syntax error

This was never intended to be valid syntax, but it worked in the old HCL
parser, and we've found a decent number of examples of it in the wild.

Fixed in https://github.com/hashicorp/hcl/pull/62 and we'll keep this
test in Terraform to cover the behavior.
This commit is contained in:
Paul Hinze 2015-11-19 09:31:33 -06:00
parent a211fc3469
commit 15e7927009
2 changed files with 34 additions and 0 deletions

View File

@ -70,6 +70,26 @@ func TestLoadFileHeredoc(t *testing.T) {
}
}
func TestLoadFileEscapedQuotes(t *testing.T) {
c, err := LoadFile(filepath.Join(fixtureDir, "escapedquotes.tf"))
if err != nil {
t.Fatalf("err: %s", err)
}
if c == nil {
t.Fatal("config should not be nil")
}
if c.Dir != "" {
t.Fatalf("bad: %#v", c.Dir)
}
actual := resourcesStr(c.Resources)
if actual != strings.TrimSpace(escapedquotesResourcesStr) {
t.Fatalf("bad:\n%s", actual)
}
}
func TestLoadFileBasic(t *testing.T) {
c, err := LoadFile(filepath.Join(fixtureDir, "basic.tf"))
if err != nil {
@ -571,6 +591,13 @@ aws_iam_policy[policy] (x1)
policy
`
const escapedquotesResourcesStr = `
aws_instance[quotes] (x1)
ami
vars
user: var.ami
`
const basicOutputsStr = `
web_ip
vars

View File

@ -0,0 +1,7 @@
variable "ami" {
default = [ "ami", "abc123" ]
}
resource "aws_instance" "quotes" {
ami = "${join(\",\", var.ami)}"
}