mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 00:41:27 -06:00
core: add context test for #5096
This commit is contained in:
parent
d8164d4d19
commit
136c228b48
@ -300,6 +300,56 @@ func TestContext2Apply_destroyComputed(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/hashicorp/terraform/pull/5096
|
||||
func TestContext2Apply_destroySkipsCBD(t *testing.T) {
|
||||
// Config contains CBD resource depending on non-CBD resource, which triggers
|
||||
// a cycle if they are both replaced, but should _not_ trigger a cycle when
|
||||
// just doing a `terraform destroy`.
|
||||
m := testModule(t, "apply-destroy-cbd")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
state := &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
Path: rootModulePath,
|
||||
Resources: map[string]*ResourceState{
|
||||
"aws_instance.foo": &ResourceState{
|
||||
Type: "aws_instance",
|
||||
Primary: &InstanceState{
|
||||
ID: "foo",
|
||||
},
|
||||
},
|
||||
"aws_instance.bar": &ResourceState{
|
||||
Type: "aws_instance",
|
||||
Primary: &InstanceState{
|
||||
ID: "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
State: state,
|
||||
Destroy: true,
|
||||
})
|
||||
|
||||
if p, err := ctx.Plan(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
} else {
|
||||
t.Logf(p.String())
|
||||
}
|
||||
|
||||
if _, err := ctx.Apply(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/hashicorp/terraform/issues/2892
|
||||
func TestContext2Apply_destroyCrossProviders(t *testing.T) {
|
||||
m := testModule(t, "apply-destroy-cross-providers")
|
||||
|
7
terraform/test-fixtures/apply-destroy-cbd/main.tf
Normal file
7
terraform/test-fixtures/apply-destroy-cbd/main.tf
Normal file
@ -0,0 +1,7 @@
|
||||
resource "aws_instance" "foo" { }
|
||||
resource "aws_instance" "bar" {
|
||||
depends_on = ["aws_instance.foo"]
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user