From 05eeff8fbbe260118543874da2273fc85673fb07 Mon Sep 17 00:00:00 2001 From: Mutahhir Hayat Date: Tue, 3 Feb 2026 14:31:42 +0100 Subject: [PATCH] Add failing test for deferred actions --- internal/stacks/stackruntime/plan_test.go | 24 +++---------------- .../mainbundle/test/deferred-action/main.tf | 2 +- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/internal/stacks/stackruntime/plan_test.go b/internal/stacks/stackruntime/plan_test.go index 61e3d6006e..9586557244 100644 --- a/internal/stacks/stackruntime/plan_test.go +++ b/internal/stacks/stackruntime/plan_test.go @@ -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)) diff --git a/internal/stacks/stackruntime/testdata/mainbundle/test/deferred-action/main.tf b/internal/stacks/stackruntime/testdata/mainbundle/test/deferred-action/main.tf index 9b88cbe0c0..8a8cc18806 100644 --- a/internal/stacks/stackruntime/testdata/mainbundle/test/deferred-action/main.tf +++ b/internal/stacks/stackruntime/testdata/mainbundle/test/deferred-action/main.tf @@ -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}"