adding context test for module multi-vars

This commit is contained in:
Luke Amdor 2014-11-28 13:16:33 -06:00
parent 4b3bf76406
commit 60022978a6
4 changed files with 53 additions and 0 deletions

View File

@ -2978,6 +2978,28 @@ func TestContextPlan_moduleInputFromVar(t *testing.T) {
t.Fatalf("bad:\n%s", actual)
}
}
func TestContextPlan_moduleMultiVar(t *testing.T) {
m := testModule(t, "plan-module-multi-var")
p := testProvider("aws")
p.DiffFn = testDiffFn
ctx := testContext(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
plan, err := ctx.Plan(nil)
if err != nil {
t.Fatalf("err: %s", err)
}
actual := strings.TrimSpace(plan.String())
expected := strings.TrimSpace(testTerraformPlanModuleMultiVarStr)
if actual != expected {
t.Fatalf("bad:\n%s", actual)
}
}
func TestContextPlan_moduleOrphans(t *testing.T) {
m := testModule(t, "plan-modules-remove")
p := testProvider("aws")

View File

@ -841,6 +841,25 @@ STATE:
<no state>
`
const testTerraformPlanModuleMultiVarStr = `
DIFF:
module.child:
CREATE: aws_instance.bar.0
baz: "" => "baz"
type: "" => "aws_instance"
CREATE: aws_instance.bar.1
baz: "" => "baz"
type: "" => "aws_instance"
CREATE: aws_instance.foo
foo: "" => "baz,baz"
type: "" => "aws_instance"
STATE:
<no state>
`
const testTerraformPlanModuleOrphansStr = `
DIFF:

View File

@ -0,0 +1,8 @@
resource "aws_instance" "bar" {
baz = "baz"
count = 2
}
resource "aws_instance" "foo" {
foo = "${join(",",aws_instance.bar.*.baz)}"
}

View File

@ -0,0 +1,4 @@
module "child" {
source = "./child"
}