Add resource with heredoc to config load tests

This test reproduces the issue which is likely the root cause of #3840.
Test is currently failing with an "illegal character" message
corresponding with the location of the heredoc, which is also seen in
various acceptance tests for providers.
This commit is contained in:
James Nugent 2015-11-10 10:15:41 -05:00
parent d1d8aca483
commit f4164b5322
2 changed files with 63 additions and 0 deletions

View File

@ -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

View File

@ -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 = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:Describe*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
EOF
}