Module: SolidFlow::Testing
- Defined in:
- lib/solid_flow/testing.rb
Class Method Summary collapse
-
.drain_execution(execution_id, max_iterations: 100) ⇒ Object
Runs an execution synchronously until it reaches a terminal state or the provided iteration limit.
- .start_and_drain(workflow_class, **input) ⇒ Object
Class Method Details
.drain_execution(execution_id, max_iterations: 100) ⇒ Object
Runs an execution synchronously until it reaches a terminal state or the provided iteration limit. Useful for unit-style workflow specs.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/solid_flow/testing.rb', line 9 def drain_execution(execution_id, max_iterations: 100) runner = SolidFlow::Runner.new max_iterations.times do runner.run(execution_id) status = SolidFlow.store.with_execution(execution_id, lock: false) do |execution| execution[:state] end break unless status == "running" end end |
.start_and_drain(workflow_class, **input) ⇒ Object
22 23 24 25 26 |
# File 'lib/solid_flow/testing.rb', line 22 def start_and_drain(workflow_class, **input) execution = workflow_class.start(**input) drain_execution(execution.id) execution end |