forked from coinbase/cadence-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync_activity_workflow_spec.rb
More file actions
34 lines (26 loc) · 954 Bytes
/
async_activity_workflow_spec.rb
File metadata and controls
34 lines (26 loc) · 954 Bytes
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
require 'workflows/async_activity_workflow'
require 'securerandom'
describe AsyncActivityWorkflow do
let(:workflow_id) { SecureRandom.uuid }
around do |example|
Cadence::Testing.local! { example.run }
ensure
$async_token = nil
end
context 'when activity completes' do
it 'succeeds' do
run_id = Cadence.start_workflow(described_class, options: { workflow_id: workflow_id })
Cadence.complete_activity($async_token)
info = Cadence.fetch_workflow_execution_info('ruby-samples', workflow_id, run_id)
expect(info).to be_completed
end
end
context 'when activity fails' do
it 'fails' do
run_id = Cadence.start_workflow(described_class, options: { workflow_id: workflow_id })
Cadence.fail_activity($async_token, StandardError.new('test failure'))
info = Cadence.fetch_workflow_execution_info('ruby-samples', workflow_id, run_id)
expect(info).to be_failed
end
end
end