-
Notifications
You must be signed in to change notification settings - Fork 89
/
parent_id_reuse_spec.rb
109 lines (93 loc) · 3.04 KB
/
parent_id_reuse_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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
require 'workflows/parent_id_reuse_workflow'
describe ParentIdReuseWorkflow, :integration do
subject { described_class }
it 'with :allow, allows duplicates' do
workflow_id = 'parent_id_reuse_wf-' + SecureRandom.uuid
child_workflow_id = 'child_id_reuse_wf-' + SecureRandom.uuid
Temporal.start_workflow(
ParentIdReuseWorkflow,
child_workflow_id,
child_workflow_id,
false,
:allow,
options: { workflow_id: workflow_id }
)
Temporal.await_workflow_result(
ParentIdReuseWorkflow,
workflow_id: workflow_id,
)
end
it 'with :reject, rejects duplicates' do
workflow_id = 'parent_id_reuse_wf-' + SecureRandom.uuid
child_workflow_id = 'child_id_reuse_wf-' + SecureRandom.uuid
Temporal.start_workflow(
ParentIdReuseWorkflow,
child_workflow_id,
child_workflow_id,
false,
:reject,
options: { workflow_id: workflow_id }
)
expect do
Temporal.await_workflow_result(
ParentIdReuseWorkflow,
workflow_id: workflow_id,
)
end.to raise_error(Temporal::WorkflowExecutionAlreadyStartedFailure,
"The child workflow could not be started - per its workflow_id_reuse_policy, it conflicts with another workflow with the same id: #{child_workflow_id}"
)
end
it 'with :reject, does not reject non-duplicates' do
workflow_id = 'parent_id_reuse_wf-' + SecureRandom.uuid
child_workflow_id_1 = 'child_id_reuse_wf-' + SecureRandom.uuid
child_workflow_id_2 = 'child_id_reuse_wf-' + SecureRandom.uuid
Temporal.start_workflow(
ParentIdReuseWorkflow,
child_workflow_id_1,
child_workflow_id_2,
false,
:reject,
options: { workflow_id: workflow_id }
)
Temporal.await_workflow_result(
ParentIdReuseWorkflow,
workflow_id: workflow_id,
)
end
it 'with :allow_failed, allows duplicates after failure' do
workflow_id = 'parent_id_reuse_wf-' + SecureRandom.uuid
child_workflow_id = 'child_id_reuse_wf-' + SecureRandom.uuid
Temporal.start_workflow(
ParentIdReuseWorkflow,
child_workflow_id,
child_workflow_id,
true,
:allow_failed,
options: { workflow_id: workflow_id }
)
Temporal.await_workflow_result(
ParentIdReuseWorkflow,
workflow_id: workflow_id,
)
end
it 'with :allow_failed, rejects duplicates after success' do
workflow_id = 'parent_id_reuse_wf-' + SecureRandom.uuid
child_workflow_id = 'child_id_reuse_wf-' + SecureRandom.uuid
Temporal.start_workflow(
ParentIdReuseWorkflow,
child_workflow_id,
child_workflow_id,
false,
:allow_failed,
options: { workflow_id: workflow_id }
)
expect do
Temporal.await_workflow_result(
ParentIdReuseWorkflow,
workflow_id: workflow_id,
)
end.to raise_error(Temporal::WorkflowExecutionAlreadyStartedFailure,
"The child workflow could not be started - per its workflow_id_reuse_policy, it conflicts with another workflow with the same id: #{child_workflow_id}"
)
end
end