terraform: test case for cascading input variables (variable to

variable)
This commit is contained in:
Mitchell Hashimoto 2014-09-23 16:55:19 -07:00
parent 9e871d5617
commit 68b38b4904
4 changed files with 57 additions and 0 deletions

View File

@ -1474,6 +1474,31 @@ func TestContextPlan_moduleInput(t *testing.T) {
}
}
func TestContextPlan_moduleInputFromVar(t *testing.T) {
m := testModule(t, "plan-module-input-var")
p := testProvider("aws")
p.DiffFn = testDiffFn
ctx := testContext(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
Variables: map[string]string{
"foo": "52",
},
})
plan, err := ctx.Plan(nil)
if err != nil {
t.Fatalf("err: %s", err)
}
actual := strings.TrimSpace(plan.String())
expected := strings.TrimSpace(testTerraformPlanModuleInputVarStr)
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

@ -528,6 +528,23 @@ STATE:
<no state>
`
const testTerraformPlanModuleInputVarStr = `
DIFF:
CREATE: aws_instance.bar
foo: "" => "2"
type: "" => "aws_instance"
module.child:
CREATE: aws_instance.foo
foo: "" => "52"
type: "" => "aws_instance"
STATE:
<no state>
`
const testTerraformPlanModuleOrphansStr = `
DIFF:

View File

@ -0,0 +1,5 @@
variable "input" {}
resource "aws_instance" "foo" {
foo = "${var.input}"
}

View File

@ -0,0 +1,10 @@
variable "foo" {}
module "child" {
input = "${var.foo}"
source = "./child"
}
resource "aws_instance" "bar" {
foo = "2"
}