|
4 | 4 | let(:namespace) { 'test-namespace' }
|
5 | 5 | let(:workflow_id) { SecureRandom.uuid }
|
6 | 6 | let(:run_id) { SecureRandom.uuid }
|
7 |
| - let(:now) { Time.now} |
| 7 | + let(:now) { Time.now.utc } |
| 8 | + let(:already_started_error) do |
| 9 | + detail_error = Google::Protobuf::Any.new.tap do |any| |
| 10 | + any.pack(Temporal::Api::ErrorDetails::V1::WorkflowExecutionAlreadyStartedFailure.new(start_request_id: SecureRandom.uuid, run_id: run_id)) |
| 11 | + end |
| 12 | + rpc_status = Google::Rpc::Status.new( |
| 13 | + code: 6, |
| 14 | + message: 'Workflow execution already finished successfully. WorkflowId: TestWorkflow-1, RunId: baaf1d86-4459-4ecd-a288-47aeae55245d. Workflow Id reuse policy: allow duplicate workflow Id if last run failed.', |
| 15 | + details: [detail_error], |
| 16 | + ) |
| 17 | + GRPC::AlreadyExists.new('details', { 'grpc-status-details-bin' => Google::Rpc::Status.encode(rpc_status) }) |
| 18 | + end |
8 | 19 |
|
9 | 20 | before do
|
10 | 21 | allow(subject).to receive(:client).and_return(grpc_stub)
|
11 |
| - |
| 22 | + |
12 | 23 | allow(Time).to receive(:now).and_return(now)
|
13 | 24 | end
|
14 | 25 |
|
15 | 26 | describe '#start_workflow_execution' do
|
16 | 27 | it 'provides the existing run_id when the workflow is already started' do
|
17 |
| - allow(grpc_stub).to receive(:start_workflow_execution).and_raise( |
18 |
| - GRPC::AlreadyExists, |
19 |
| - 'Workflow execution already finished successfully. WorkflowId: TestWorkflow-1, RunId: baaf1d86-4459-4ecd-a288-47aeae55245d. Workflow Id reuse policy: allow duplicate workflow Id if last run failed.' |
20 |
| - ) |
| 28 | + allow(grpc_stub).to receive(:start_workflow_execution).and_raise(already_started_error) |
21 | 29 |
|
22 | 30 | expect do
|
23 | 31 | subject.start_workflow_execution(
|
|
31 | 39 | memo: {}
|
32 | 40 | )
|
33 | 41 | end.to raise_error(Temporal::WorkflowExecutionAlreadyStartedFailure) do |e|
|
34 |
| - expect(e.run_id).to eql('baaf1d86-4459-4ecd-a288-47aeae55245d') |
| 42 | + expect(e.run_id).to eql(run_id) |
35 | 43 | end
|
36 | 44 | end
|
37 | 45 | end
|
38 |
| - |
| 46 | + |
39 | 47 | describe '#signal_with_start_workflow' do
|
40 | 48 | let(:temporal_response) do
|
41 | 49 | Temporal::Api::WorkflowService::V1::SignalWithStartWorkflowExecutionResponse.new(run_id: 'xxx')
|
|
148 | 156 | end
|
149 | 157 | end
|
150 | 158 |
|
151 |
| - it 'demands a timeout to be specified' do |
| 159 | + it 'demands a timeout to be specified' do |
152 | 160 | expect do
|
153 | 161 | subject.get_workflow_execution_history(
|
154 | 162 | namespace: namespace,
|
|
161 | 169 | end
|
162 | 170 | end
|
163 | 171 |
|
164 |
| - it 'disallows a timeout larger than the server timeout' do |
| 172 | + it 'disallows a timeout larger than the server timeout' do |
165 | 173 | expect do
|
166 | 174 | subject.get_workflow_execution_history(
|
167 | 175 | namespace: namespace,
|
|
0 commit comments