fix tests after moving incorrect references
The destroy graph builder test requires state in order to be correct, which it didn't have. The other tests hits the edge case where a planned destroy cannot remove outputs, because the apply phase does not know it was created from a destroy.
This commit is contained in:
parent
ebe31acc48
commit
ca8338e343
|
@ -6033,10 +6033,8 @@ func TestContext2Apply_destroyModuleWithAttrsReferencingResource(t *testing.T) {
|
|||
}
|
||||
|
||||
//Test that things were destroyed
|
||||
actual := strings.TrimSpace(state.String())
|
||||
expected := strings.TrimSpace(`<no state>`)
|
||||
if actual != expected {
|
||||
t.Fatalf("expected:\n\n%s\n\nactual:\n\n%s", expected, actual)
|
||||
if state.HasResources() {
|
||||
t.Fatal("expected empty state, got:", state)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -321,11 +321,33 @@ func TestApplyGraphBuilder_destroyCount(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
state := states.NewState()
|
||||
root := state.RootModule()
|
||||
addrA := mustResourceInstanceAddr("test_object.A[1]")
|
||||
root.SetResourceInstanceCurrent(
|
||||
addrA.Resource,
|
||||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"B"}`),
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/hashicorp/test"]`),
|
||||
)
|
||||
root.SetResourceInstanceCurrent(
|
||||
mustResourceInstanceAddr("test_object.B").Resource,
|
||||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"B"}`),
|
||||
Dependencies: []addrs.ConfigResource{addrA.ContainingResource().Config()},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/hashicorp/test"]`),
|
||||
)
|
||||
|
||||
b := &ApplyGraphBuilder{
|
||||
Config: testModule(t, "graph-builder-apply-count"),
|
||||
Changes: changes,
|
||||
Components: simpleMockComponentFactory(),
|
||||
Schemas: simpleTestSchemas(),
|
||||
State: state,
|
||||
}
|
||||
|
||||
g, err := b.Build(addrs.RootModuleInstance)
|
||||
|
|
Loading…
Reference in New Issue