From 5739ed99f55105674247f3a25f1ca60b0cc01811 Mon Sep 17 00:00:00 2001 From: James Kong Date: Mon, 25 May 2026 22:15:39 +0800 Subject: [PATCH] feat: add ExecChangeset function to runtime This updates the ExecChangeset function to return the changeset output instead of the task ID. This is more useful for testing purposes than the task ID. --- engine/test/runtime/runtime.go | 13 +++++++++++-- engine/test/runtime/runtime_test.go | 5 ++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/engine/test/runtime/runtime.go b/engine/test/runtime/runtime.go index e77d555df..9dda2d40e 100644 --- a/engine/test/runtime/runtime.go +++ b/engine/test/runtime/runtime.go @@ -92,10 +92,19 @@ func (r *Runtime) Exec(executables ...Executable) error { // Go does not allow type parameters on methods. // // Returns the task ID and error if the changeset execution fails. -func ExecChangeset[C any](r *Runtime, changeset fdeployment.ChangeSetV2[C], config C) (string, error) { +func ExecChangeset[C any](r *Runtime, changeset fdeployment.ChangeSetV2[C], config C) (fdeployment.ChangesetOutput, error) { task := ChangesetTask(changeset, config) - return task.ID(), r.Exec(task) + if err := r.Exec(task); err != nil { + return fdeployment.ChangesetOutput{}, err + } + + output, ok := r.state.Outputs[task.ID()] + if !ok { + return fdeployment.ChangesetOutput{}, fmt.Errorf("changeset output not found for task %s", task.ID()) + } + + return output, nil } // State returns the current state of the runtime. diff --git a/engine/test/runtime/runtime_test.go b/engine/test/runtime/runtime_test.go index ffed2a403..dffc1d093 100644 --- a/engine/test/runtime/runtime_test.go +++ b/engine/test/runtime/runtime_test.go @@ -354,10 +354,9 @@ func TestRuntime_ExecChangeset(t *testing.T) { changeset := &mockChangeset[mockChangesetConfig]{} config := mockChangesetConfig{Value: "test"} - taskID, err := ExecChangeset(runtime, changeset, config) + output, err := ExecChangeset(runtime, changeset, config) require.NoError(t, err) - require.NotEmpty(t, taskID) - require.Contains(t, runtime.state.Outputs, taskID) + require.NotNil(t, output) } func TestRuntime_State(t *testing.T) {