terraform: test case for destroying with a count [GH-527]

This commit is contained in:
Mitchell Hashimoto 2015-02-20 10:02:52 -08:00
parent 79648add00
commit ab414de0ab
3 changed files with 53 additions and 0 deletions

View File

@ -3229,6 +3229,48 @@ func TestContext2Apply_module(t *testing.T) {
}
}
func TestContext2Apply_moduleVarResourceCount(t *testing.T) {
m := testModule(t, "apply-module-var-resource-count")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
Variables: map[string]string{
"count": "2",
},
})
if _, err := ctx.Plan(nil); err != nil {
t.Fatalf("err: %s", err)
}
if _, err := ctx.Apply(); err != nil {
t.Fatalf("err: %s", err)
}
ctx = testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
Variables: map[string]string{
"count": "5",
},
})
if _, err := ctx.Plan(&PlanOpts{Destroy: true}); err != nil {
t.Fatalf("err: %s", err)
}
if _, err := ctx.Apply(); err != nil {
t.Fatalf("err: %s", err)
}
}
func TestContext2Apply_multiProvider(t *testing.T) {
m := testModule(t, "apply-multi-provider")
p := testProvider("aws")

View File

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

View File

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