mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
test references only from output preconditions
These references were getting dropped, which could cause the referenced nodes to be pruned from the graph.
This commit is contained in:
parent
1790f844b3
commit
45cb0489d0
@ -1784,3 +1784,51 @@ resource "test_object" "y" {
|
|||||||
_, diags = ctx.Apply(plan, m)
|
_, diags = ctx.Apply(plan, m)
|
||||||
assertNoErrors(t, diags)
|
assertNoErrors(t, diags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensure all references from preconditions are tracked through plan and apply
|
||||||
|
func TestContext2Apply_preconditionErrorMessageRef(t *testing.T) {
|
||||||
|
p := testProvider("test")
|
||||||
|
ctx := testContext2(t, &ContextOpts{
|
||||||
|
Providers: map[addrs.Provider]providers.Factory{
|
||||||
|
addrs.NewDefaultProvider("test"): testProviderFuncFixed(p),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
m := testModuleInline(t, map[string]string{
|
||||||
|
"main.tf": `
|
||||||
|
module "nested" {
|
||||||
|
source = "./mod"
|
||||||
|
}
|
||||||
|
|
||||||
|
output "nested_a" {
|
||||||
|
value = module.nested.a
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
|
||||||
|
"mod/main.tf": `
|
||||||
|
variable "boop" {
|
||||||
|
default = "boop"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "msg" {
|
||||||
|
default = "Incorrect boop."
|
||||||
|
}
|
||||||
|
|
||||||
|
output "a" {
|
||||||
|
value = "x"
|
||||||
|
|
||||||
|
precondition {
|
||||||
|
condition = var.boop == "boop"
|
||||||
|
error_message = var.msg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
|
||||||
|
plan, diags := ctx.Plan(m, states.NewState(), &PlanOpts{
|
||||||
|
Mode: plans.NormalMode,
|
||||||
|
})
|
||||||
|
assertNoErrors(t, diags)
|
||||||
|
_, diags = ctx.Apply(plan, m)
|
||||||
|
assertNoErrors(t, diags)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user