mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
add failing test for orphaned modules outputs
When an entire module is removed from the config, that module's outputs are not removed from the state.
This commit is contained in:
parent
00b7715710
commit
68b07a766a
@ -4036,7 +4036,7 @@ func TestContext2Apply_outputOrphanModule(t *testing.T) {
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state,
|
||||
State: state.DeepCopy(),
|
||||
})
|
||||
|
||||
if _, err := ctx.Plan(); err != nil {
|
||||
@ -4051,7 +4051,34 @@ func TestContext2Apply_outputOrphanModule(t *testing.T) {
|
||||
actual := strings.TrimSpace(state.String())
|
||||
expected := strings.TrimSpace(testTerraformApplyOutputOrphanModuleStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: \n%s", actual)
|
||||
t.Fatalf("expected:\n%s\n\ngot:\n%s", expected, actual)
|
||||
}
|
||||
|
||||
// now apply with no module in the config, which should remove the
|
||||
// remaining output
|
||||
ctx = testContext2(t, &ContextOpts{
|
||||
Module: module.NewEmptyTree(),
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state.DeepCopy(),
|
||||
})
|
||||
|
||||
if _, err := ctx.Plan(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
state, err = ctx.Apply()
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
expected = "<no state>"
|
||||
actual = strings.TrimSpace(state.String())
|
||||
if actual != expected {
|
||||
t.Fatalf("expected:\n%s\n\ngot:\n%s", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user