core: add failing deeply nested orphan module test

I was worried about the implications of deeply nested orphaned modules
in the parent commit, so I added a test. It's failing but not quite like
I expected it to. Perhaps I've uncovered an unrelated bug here?

/cc @mitchellh
This commit is contained in:
Paul Hinze 2015-07-20 10:18:29 -05:00
parent edd05f2aa2
commit 392f56101c
5 changed files with 63 additions and 0 deletions

View File

@ -2145,6 +2145,57 @@ func TestContext2Apply_destroyNestedModule(t *testing.T) {
}
}
func TestContext2Apply_destroyDeeplyNestedModule(t *testing.T) {
m := testModule(t, "apply-destroy-deeply-nested-module")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
s := &State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child", "subchild", "subsubchild"},
Resources: map[string]*ResourceState{
"aws_instance.bar": &ResourceState{
Type: "aws_instance",
Primary: &InstanceState{
ID: "bar",
},
},
},
},
},
}
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
State: s,
})
// First plan and apply a create operation
if _, err := ctx.Plan(); err != nil {
t.Fatalf("err: %s", err)
}
state, err := ctx.Apply()
if err != nil {
t.Fatalf("err: %s", err)
}
// Test that things were destroyed
actual := strings.TrimSpace(state.String())
expected := strings.TrimSpace(`
module.child.subchild.subsubchild:
<no state>
`)
if actual != expected {
t.Fatalf("bad: \n%s", actual)
}
}
func TestContext2Apply_destroyOutputs(t *testing.T) {
m := testModule(t, "apply-destroy-outputs")
h := new(HookRecordApplyOrder)

View File

@ -0,0 +1,3 @@
module "subchild" {
source = "./subchild"
}

View File

@ -0,0 +1,5 @@
/*
module "subsubchild" {
source = "./subsubchild"
}
*/

View File

@ -0,0 +1 @@
resource "aws_instance" "bar" {}

View File

@ -0,0 +1,3 @@
module "child" {
source = "./child"
}