diff --git a/config/loader_test.go b/config/loader_test.go index 18b26f9c5..5be023cb1 100644 --- a/config/loader_test.go +++ b/config/loader_test.go @@ -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 diff --git a/config/test-fixtures/escapedquotes.tf b/config/test-fixtures/escapedquotes.tf new file mode 100644 index 000000000..4fe9a020b --- /dev/null +++ b/config/test-fixtures/escapedquotes.tf @@ -0,0 +1,7 @@ +variable "ami" { + default = [ "ami", "abc123" ] +} + +resource "aws_instance" "quotes" { + ami = "${join(\",\", var.ami)}" +}