forked from coinbase/temporal-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signal_spec.rb
40 lines (35 loc) · 926 Bytes
/
signal_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'securerandom'
require 'workflows/signal_workflow'
describe 'signal' do
it 'all signals process' do
workflow_id = SecureRandom.uuid
expected_score = 7
run_id = Temporal.start_workflow(
SignalWorkflow,
1, # seconds
options: {
workflow_id: workflow_id,
signal_name: 'score',
signal_input: expected_score,
timeouts: { execution: 10 }
}
)
loop do
value = SecureRandom.rand(10)
begin
Temporal.signal_workflow(SignalWorkflow, 'score', workflow_id, run_id, value)
rescue StandardError
# Keep going until there's an error such as the workflow finishing
break
end
expected_score += value
sleep 0.01
end
result = Temporal.await_workflow_result(
SignalWorkflow,
workflow_id: workflow_id,
run_id: run_id
)
expect(result).to eq(expected_score)
end
end