terraform: test static var being passed into grandchild for count

This commit is contained in:
Mitchell Hashimoto 2017-01-27 20:38:07 -08:00
parent 2162d6cf3d
commit 0ba3fcdc63
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
4 changed files with 51 additions and 0 deletions

View File

@ -1511,6 +1511,40 @@ STATE:
}
}
func TestContext2Plan_countModuleStaticGrandchild(t *testing.T) {
m := testModule(t, "plan-count-module-static-grandchild")
p := testProvider("aws")
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
plan, err := ctx.Plan()
if err != nil {
t.Fatalf("err: %s", err)
}
actual := strings.TrimSpace(plan.String())
expected := strings.TrimSpace(`
DIFF:
module.child.child:
CREATE: aws_instance.foo.0
CREATE: aws_instance.foo.1
CREATE: aws_instance.foo.2
STATE:
<no state>
`)
if actual != expected {
t.Fatalf("bad:\n%s", actual)
}
}
func TestContext2Plan_countIndex(t *testing.T) {
m := testModule(t, "plan-count-index")
p := testProvider("aws")

View File

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

View File

@ -0,0 +1,6 @@
variable "value" {}
module "child" {
source = "./child"
value = "${var.value}"
}

View File

@ -0,0 +1,6 @@
variable "foo" { default = "3" }
module "child" {
source = "./child"
value = "${var.foo}"
}