Cyclium.Test.WorkflowCase (Cyclium v0.1.9)

Copy Markdown View Source

Test helpers for validating workflow definitions.

Checks DAG validity, step input functions, failure policy coverage, and structural correctness for both compiled and dynamic workflows.

Usage

defmodule MyApp.Workflows.VendorOnboardingTest do
  use ExUnit.Case, async: true
  use Cyclium.Test.WorkflowCase

  test "workflow is valid" do
    assert_valid_workflow(MyApp.Workflows.VendorOnboarding)
  end

  test "step inputs don't crash" do
    assert_step_inputs_safe(MyApp.Workflows.VendorOnboarding,
      trigger: %{"vendor_id" => "v123"}
    )
  end
end

Summary

Functions

Assert that every step has a failure policy defined. Useful for enforcing that teams explicitly handle failures for all steps.

Assert that all failure policies reference existing steps and use valid policy types.

Assert that all step input functions execute without crashing for the given trigger payload. Uses empty prior results for root steps and mock prior results for dependent steps.

Assert that a workflow module has a valid definition: trigger set, steps form a DAG, no duplicate IDs, all depends_on references exist.

Functions

assert_failure_policies_complete(workflow_module)

(macro)

Assert that every step has a failure policy defined. Useful for enforcing that teams explicitly handle failures for all steps.

assert_failure_policies_valid(workflow_module)

(macro)

Assert that all failure policies reference existing steps and use valid policy types.

assert_step_inputs_safe(workflow_module, opts)

(macro)

Assert that all step input functions execute without crashing for the given trigger payload. Uses empty prior results for root steps and mock prior results for dependent steps.

Options

  • :trigger — trigger payload map (required)
  • :prior — mock prior step results (default: auto-generated empty maps)

assert_valid_workflow(workflow_module)

(macro)

Assert that a workflow module has a valid definition: trigger set, steps form a DAG, no duplicate IDs, all depends_on references exist.