|
|
|
|
@ -1477,6 +1477,74 @@ func TestContext2Plan_countComputedModule(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestContext2Plan_countModuleStatic(t *testing.T) {
|
|
|
|
|
m := testModule(t, "plan-count-module-static")
|
|
|
|
|
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:
|
|
|
|
|
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_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")
|
|
|
|
|
|