terraform: test case for destroying with a count [GH-527]
This commit is contained in:
parent
79648add00
commit
ab414de0ab
|
@ -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) {
|
func TestContext2Apply_multiProvider(t *testing.T) {
|
||||||
m := testModule(t, "apply-multi-provider")
|
m := testModule(t, "apply-multi-provider")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
variable "count" {}
|
||||||
|
|
||||||
|
resource "aws_instance" "foo" {
|
||||||
|
count = "${var.count}"
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
variable "count" {}
|
||||||
|
|
||||||
|
module "child" {
|
||||||
|
source = "./child"
|
||||||
|
count = "${var.count}"
|
||||||
|
}
|
Loading…
Reference in New Issue