diff --git a/config/loader_test.go b/config/loader_test.go index eaf4f10aa..18b26f9c5 100644 --- a/config/loader_test.go +++ b/config/loader_test.go @@ -45,6 +45,31 @@ func TestLoadFile_badType(t *testing.T) { } } +func TestLoadFileHeredoc(t *testing.T) { + c, err := LoadFile(filepath.Join(fixtureDir, "heredoc.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 := providerConfigsStr(c.ProviderConfigs) + if actual != strings.TrimSpace(heredocProvidersStr) { + t.Fatalf("bad:\n%s", actual) + } + + actual = resourcesStr(c.Resources) + if actual != strings.TrimSpace(heredocResourcesStr) { + t.Fatalf("bad:\n%s", actual) + } +} + func TestLoadFileBasic(t *testing.T) { c, err := LoadFile(filepath.Join(fixtureDir, "basic.tf")) if err != nil { @@ -532,6 +557,20 @@ func TestLoad_temporary_files(t *testing.T) { } } +const heredocProvidersStr = ` +aws + access_key + secret_key +` + +const heredocResourcesStr = ` +aws_iam_policy[policy] (x1) + description + name + path + policy +` + const basicOutputsStr = ` web_ip vars diff --git a/config/test-fixtures/heredoc.tf b/config/test-fixtures/heredoc.tf new file mode 100644 index 000000000..b765a58f0 --- /dev/null +++ b/config/test-fixtures/heredoc.tf @@ -0,0 +1,24 @@ +provider "aws" { + access_key = "foo" + secret_key = "bar" +} + +resource "aws_iam_policy" "policy" { + name = "test_policy" + path = "/" + description = "My test policy" + policy = <