-
Notifications
You must be signed in to change notification settings - Fork 89
/
signal_with_start_spec.rb
75 lines (65 loc) · 1.96 KB
/
signal_with_start_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require 'workflows/signal_with_start_workflow'
describe 'signal with start' do
it 'signals at workflow start time' do
workflow_id = SecureRandom.uuid
run_id = Temporal.start_workflow(
SignalWithStartWorkflow,
'signal_name',
options: {
workflow_id: workflow_id,
signal_name: 'signal_name',
signal_input: 'expected value',
timeouts: { execution: 10 },
}
)
result = Temporal.await_workflow_result(
SignalWithStartWorkflow,
workflow_id: workflow_id,
run_id: run_id,
)
expect(result).to eq('expected value') # the workflow should return the signal value
end
it 'signals at workflow start time with name only' do
workflow_id = SecureRandom.uuid
run_id = Temporal.start_workflow(
SignalWithStartWorkflow,
'signal_name',
options: {
workflow_id: workflow_id,
signal_name: 'signal_name',
timeouts: { execution: 10 },
}
)
result = Temporal.await_workflow_result(
SignalWithStartWorkflow,
workflow_id: workflow_id,
run_id: run_id,
)
expect(result).to eq(nil) # the workflow should return the signal value
end
it 'does not launch a new workflow when signaling a running workflow through signal_with_start' do
workflow_id = SecureRandom.uuid
run_id = Temporal.start_workflow(
SignalWithStartWorkflow,
'signal_name',
options: {
workflow_id: workflow_id,
signal_name: 'signal_name',
signal_input: 'expected value',
timeouts: { execution: 10 },
}
)
second_run_id = Temporal.start_workflow(
SignalWithStartWorkflow,
'signal_name',
options: {
workflow_id: workflow_id,
signal_name: 'signal_name',
signal_input: 'expected value',
timeouts: { execution: 10 },
}
)
# If the run ids are the same, then we didn't start a new workflow
expect(second_run_id).to eq(run_id)
end
end