forked from coinbase/temporal-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metadata_workflow_spec.rb
91 lines (75 loc) · 2.47 KB
/
metadata_workflow_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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require 'workflows/metadata_workflow'
describe MetadataWorkflow, :integration do
subject { described_class }
it 'gets task queue from running workflow' do
workflow_id = 'task-queue-' + SecureRandom.uuid
run_id = Temporal.start_workflow(
subject,
options: { workflow_id: workflow_id }
)
actual_result = Temporal.await_workflow_result(
subject,
workflow_id: workflow_id,
run_id: run_id,
)
expect(actual_result.task_queue).to eq(Temporal.configuration.task_queue)
end
it 'workflow can retrieve its headers' do
workflow_id = 'header_test_wf-' + SecureRandom.uuid
run_id = Temporal.start_workflow(
MetadataWorkflow,
options: {
workflow_id: workflow_id,
headers: { 'foo' => 'bar' },
}
)
actual_result = Temporal.await_workflow_result(
MetadataWorkflow,
workflow_id: workflow_id,
run_id: run_id,
)
expect(actual_result.headers).to eq({ 'foo' => 'bar' })
end
it 'workflow can retrieve its run started at' do
workflow_id = 'started_at_test_wf-' + SecureRandom.uuid
run_id = Temporal.start_workflow(
MetadataWorkflow,
options: { workflow_id: workflow_id }
)
actual_result = Temporal.await_workflow_result(
MetadataWorkflow,
workflow_id: workflow_id,
run_id: run_id,
)
expect(Time.now - actual_result.run_started_at).to be_between(0, 30)
end
it 'gets memo from workflow execution info' do
workflow_id = 'memo_execution_test_wf-' + SecureRandom.uuid
run_id = Temporal.start_workflow(subject, options: { workflow_id: workflow_id, memo: { 'foo' => 'bar' } })
actual_result = Temporal.await_workflow_result(
subject,
workflow_id: workflow_id,
run_id: run_id,
)
expect(actual_result.memo['foo']).to eq('bar')
expect(Temporal.fetch_workflow_execution_info(
integration_spec_namespace, workflow_id, nil
).memo).to eq({ 'foo' => 'bar' })
end
it 'gets memo from workflow context with no memo' do
workflow_id = 'memo_context_no_memo_test_wf-' + SecureRandom.uuid
run_id = Temporal.start_workflow(
subject,
options: { workflow_id: workflow_id }
)
actual_result = Temporal.await_workflow_result(
subject,
workflow_id: workflow_id,
run_id: run_id,
)
expect(actual_result.memo).to eq({})
expect(Temporal.fetch_workflow_execution_info(
integration_spec_namespace, workflow_id, nil
).memo).to eq({})
end
end