Add failing test for deferred actions

pull/38243/head^2
Mutahhir Hayat 3 months ago committed by Daniel Schmidt
parent ffeff0914d
commit 05eeff8fbb

@ -6573,33 +6573,15 @@ func TestPlanWithDeferredActionInvocation(t *testing.T) {
return plannedChangeSortKey(gotChanges[i]) < plannedChangeSortKey(gotChanges[j])
})
// First, let's verify the resource was actually deferred
var foundDeferredResource bool
var foundNormalActionInvocation bool
// Find the deferred action invocation in the changes
var foundDeferredAction bool
for _, change := range gotChanges {
switch c := change.(type) {
case *stackplan.PlannedChangeDeferredResourceInstancePlanned:
foundDeferredResource = true
t.Logf("Found deferred resource: %s", c.ResourceInstancePlanned.ResourceInstanceObjectAddr)
case *stackplan.PlannedChangeActionInvocationInstancePlanned:
foundNormalActionInvocation = true
t.Logf("Found normal action invocation: %s", c.ActionInvocationAddr)
case *stackplan.PlannedChangeDeferredActionInvocation:
if _, ok := change.(*stackplan.PlannedChangeDeferredActionInvocation); ok {
foundDeferredAction = true
t.Logf("Found deferred action invocation: %s", c.ActionInvocationPlanned.ActionInvocationAddr)
break
}
}
if !foundDeferredResource {
t.Error("Expected to find a deferred resource, but none was found")
}
if foundNormalActionInvocation {
t.Error("Action invocation should be deferred, not appearing as a normal invocation")
}
if !foundDeferredAction {
t.Error("Expected to find a deferred action invocation in the plan changes, but none was found")
t.Logf("Got %d changes:", len(gotChanges))

@ -18,7 +18,7 @@ variable "defer" {
type = bool
}
# Simple action
# Action that should be invoked when resource is created
action "testing_action" "notify" {
config {
message = "resource created with id ${var.id}"

Loading…
Cancel
Save