Merge pull request #3842 from hashicorp/b-heredoc-loading

Add resource with heredoc to config load tests
This commit is contained in:
James Nugent 2015-11-10 18:19:34 -05:00
commit 8cca366d21
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
}