mirror of
https://github.com/hashicorp/terraform.git
synced 2026-05-28 04:03:27 -04:00
Add failing test for deferred actions
This commit is contained in:
parent
ffeff0914d
commit
05eeff8fbb
2 changed files with 4 additions and 22 deletions
|
|
@ -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…
Reference in a new issue