mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 00:41:27 -06:00
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:
parent
edd05f2aa2
commit
392f56101c
@ -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)
|
||||
|
@ -0,0 +1,3 @@
|
||||
module "subchild" {
|
||||
source = "./subchild"
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
/*
|
||||
module "subsubchild" {
|
||||
source = "./subsubchild"
|
||||
}
|
||||
*/
|
@ -0,0 +1 @@
|
||||
resource "aws_instance" "bar" {}
|
@ -0,0 +1,3 @@
|
||||
module "child" {
|
||||
source = "./child"
|
||||
}
|
Loading…
Reference in New Issue
Block a user