Add test for action invocation
diff --git a/plan_test.go b/plan_test.go
index c97f8f9..9776b9b 100644
--- a/plan_test.go
+++ b/plan_test.go
@@ -136,6 +136,48 @@
}
}
+func TestPlan_actionInvocations(t *testing.T) {
+ f, err := os.Open("testdata/actions/plan.json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.Close()
+
+ var plan *Plan
+ if err := json.NewDecoder(f).Decode(&plan); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := plan.Validate(); err != nil {
+ t.Fatal(err)
+ }
+
+ if len(plan.ActionInvocations) != 1 {
+ t.Fatalf("expected exactly 1 action invocation, got %d", len(plan.ActionInvocations))
+ }
+
+ expectedAction := []*ActionInvocation{
+ {
+ Address: "action.bufo_print.success",
+ Type: "bufo_print",
+ Name: "success",
+ ConfigValues: map[string]json.RawMessage{
+ "color": json.RawMessage("null"),
+ "name": json.RawMessage(`"bufo-the-builder"`),
+ "ratio": json.RawMessage("null"),
+ },
+ ConfigSensitive: json.RawMessage("{}"),
+ ProviderName: "registry.terraform.io/austinvalle/bufo",
+ LifecycleActionTrigger: nil,
+ InvokeActionTrigger: &InvokeActionTrigger{},
+ },
+ }
+
+ if diff := cmp.Diff(expectedAction, plan.ActionInvocations); diff != "" {
+ t.Fatalf("unexpected action invocation: %s", diff)
+ }
+}
+
func TestPlan_UnmarshalJSON(t *testing.T) {
t.Parallel()
@@ -168,7 +210,6 @@
plan.UseJSONNumber(testCase.useJSONNumber)
err = plan.UnmarshalJSON(b)
-
if err != nil {
t.Fatal(err)
}
diff --git a/testdata/actions/plan.json b/testdata/actions/plan.json
new file mode 100644
index 0000000..0ef1341
--- /dev/null
+++ b/testdata/actions/plan.json
@@ -0,0 +1,41 @@
+{
+ "format_version": "1.2",
+ "planned_values": { "root_module": {} },
+ "action_invocations": [
+ {
+ "address": "action.bufo_print.success",
+ "type": "bufo_print",
+ "name": "success",
+ "config_values": {
+ "color": null,
+ "name": "bufo-the-builder",
+ "ratio": null
+ },
+ "config_sensitive": {},
+ "provider_name": "registry.terraform.io/austinvalle/bufo",
+ "invoke_action_trigger": {}
+ }
+ ],
+ "configuration": {
+ "provider_config": {
+ "bufo": {
+ "name": "bufo",
+ "full_name": "registry.terraform.io/austinvalle/bufo"
+ }
+ },
+ "root_module": {
+ "actions": [
+ {
+ "address": "action.bufo_print.success",
+ "type": "bufo_print",
+ "name": "success",
+ "provider_config_key": "bufo"
+ }
+ ]
+ }
+ },
+ "timestamp": "2025-09-12T09:56:02Z",
+ "applyable": true,
+ "complete": true,
+ "errored": false
+}