tests for ephemeral conditions

pull/35920/head
James Bardin 2 years ago
parent dee28f5030
commit 7a130f6169

@ -425,6 +425,54 @@ module "child" {
})
},
},
"resource precondition": {
module: map[string]string{
"main.tf": `
locals {
test_value = 2
}
ephemeral "ephem_resource" "data" {
lifecycle {
precondition {
condition = local.test_value != 2
error_message = "value should not be 2"
}
}
}
`,
},
expectPlanDiagnostics: func(m *configs.Config) (diags tfdiags.Diagnostics) {
return diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Resource precondition failed",
Detail: "value should not be 2",
})
},
},
"resource postcondition": {
module: map[string]string{
"main.tf": `
locals {
test_value = 2
}
ephemeral "ephem_resource" "data" {
lifecycle {
postcondition {
condition = self.value == "pass"
error_message = "value should be \"pass\""
}
}
}
`,
},
expectPlanDiagnostics: func(m *configs.Config) (diags tfdiags.Diagnostics) {
return diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Resource postcondition failed",
Detail: `value should be "pass"`,
})
},
},
} {
t.Run(name, func(t *testing.T) {
if tc.toBeImplemented {

Loading…
Cancel
Save