forked from coinbase/temporal-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivity_cancellation_spec.rb
36 lines (29 loc) · 1.06 KB
/
activity_cancellation_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
require 'workflows/long_workflow'
describe 'Activity cancellation', :integration do
it 'cancels a running activity' do
workflow_id, run_id = run_workflow(LongWorkflow)
# Signal workflow after starting, allowing it to schedule the first activity
sleep 0.5
Temporal.signal_workflow(LongWorkflow, :CANCEL, workflow_id, run_id)
result = Temporal.await_workflow_result(
LongWorkflow,
workflow_id: workflow_id,
run_id: run_id,
)
expect(result).to be_a(LongRunningActivity::Canceled)
expect(result.message).to eq('cancel activity request received')
end
it 'cancels a non-started activity' do
# Workflow is started with a signal which will cancel an activity before it has started
workflow_id, run_id = run_workflow(LongWorkflow, options: {
signal_name: :CANCEL
})
result = Temporal.await_workflow_result(
LongWorkflow,
workflow_id: workflow_id,
run_id: run_id,
)
expect(result).to be_a(Temporal::ActivityCanceled)
expect(result.message).to eq('ACTIVITY_ID_NOT_STARTED')
end
end