mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
always report condition errors
The status in the face of errors didn't matter before, because we never wrote out a plan with errors.
This commit is contained in:
parent
5aa088e385
commit
bb5f360747
@ -3379,10 +3379,15 @@ func TestContext2Plan_preconditionErrors(t *testing.T) {
|
||||
`, tc.condition)
|
||||
m := testModuleInline(t, map[string]string{"main.tf": main})
|
||||
|
||||
_, diags := ctx.Plan(m, states.NewState(), DefaultPlanOpts)
|
||||
plan, diags := ctx.Plan(m, states.NewState(), DefaultPlanOpts)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
|
||||
if !plan.Errored {
|
||||
t.Fatal("plan failed to record error")
|
||||
}
|
||||
|
||||
diag := diags[0]
|
||||
if got, want := diag.Description().Summary, tc.wantSummary; got != want {
|
||||
t.Errorf("unexpected summary\n got: %s\nwant: %s", got, want)
|
||||
@ -3390,6 +3395,13 @@ func TestContext2Plan_preconditionErrors(t *testing.T) {
|
||||
if got, want := diag.Description().Detail, tc.wantDetail; !strings.Contains(got, want) {
|
||||
t.Errorf("unexpected summary\ngot: %s\nwant to contain %q", got, want)
|
||||
}
|
||||
|
||||
for _, kv := range plan.Checks.ConfigResults.Elements() {
|
||||
// All these are configuration or evaluation errors
|
||||
if kv.Value.Status != checks.StatusError {
|
||||
t.Errorf("incorrect status, got %s", kv.Value.Status)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -103,6 +103,7 @@ func evalCheckRule(typ addrs.CheckType, rule *configs.CheckRule, ctx EvalContext
|
||||
|
||||
if diags.HasErrors() {
|
||||
log.Printf("[TRACE] evalCheckRule: %s: %s", typ, diags.Err().Error())
|
||||
return checkResult{Status: checks.StatusError}, diags
|
||||
}
|
||||
|
||||
if !resultVal.IsKnown() {
|
||||
|
Loading…
Reference in New Issue
Block a user