core: TestContext2Apply_multiDepose_createBeforeDestroy incorrect logic
This test was re-using the same context to run three consecutive plan/apply operations, which is not safe because we will accumulate more planned changes with each change, creating duplicate entries in the diff. Instead, to properly simulate a sequence of consecutive runs of Terraform we must start with a fresh context each time, though still pass forward the previous state which would in the real world be persisted via a state manager between these runs.
This commit is contained in:
parent
d40b6c128d
commit
d0069f721e
|
@ -4761,6 +4761,11 @@ aws_instance.web: (2 deposed)
|
|||
}
|
||||
|
||||
createdInstanceId = "qux"
|
||||
ctx = testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
ProviderResolver: providers.ResolverFixed(ps),
|
||||
State: state,
|
||||
})
|
||||
if _, diags := ctx.Plan(); diags.HasErrors() {
|
||||
t.Fatalf("plan errors: %s", diags.Err())
|
||||
}
|
||||
|
@ -4784,6 +4789,11 @@ aws_instance.web: (1 deposed)
|
|||
}
|
||||
|
||||
createdInstanceId = "quux"
|
||||
ctx = testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
ProviderResolver: providers.ResolverFixed(ps),
|
||||
State: state,
|
||||
})
|
||||
if _, diags := ctx.Plan(); diags.HasErrors() {
|
||||
t.Fatalf("plan errors: %s", diags.Err())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue