Module: Temporal::Testing::TemporalOverride

Defined in:
lib/temporal/testing/temporal_override.rb

Instance Method Summary collapse

Instance Method Details

#complete_activity(async_token, result = nil) ⇒ Object


48
49
50
51
52
53
54
55
# File 'lib/temporal/testing/temporal_override.rb', line 48

def complete_activity(async_token, result = nil)
  return super if Temporal::Testing.disabled?

  details = Activity::AsyncToken.decode(async_token)
  execution = executions[[details.workflow_id, details.run_id]]

  execution.complete_activity(async_token, result)
end

#fail_activity(async_token, exception) ⇒ Object


57
58
59
60
61
62
63
64
# File 'lib/temporal/testing/temporal_override.rb', line 57

def fail_activity(async_token, exception)
  return super if Temporal::Testing.disabled?

  details = Activity::AsyncToken.decode(async_token)
  execution = executions[[details.workflow_id, details.run_id]]

  execution.fail_activity(async_token, exception)
end

#fetch_workflow_execution_info(_namespace, workflow_id, run_id) ⇒ Object


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/temporal/testing/temporal_override.rb', line 32

def fetch_workflow_execution_info(_namespace, workflow_id, run_id)
  return super if Temporal::Testing.disabled?

  execution = executions[[workflow_id, run_id]]

  Workflow::ExecutionInfo.new(
    workflow: nil,
    workflow_id: workflow_id,
    run_id: run_id,
    start_time: nil,
    close_time: nil,
    status: execution.status,
    history_length: nil,
  ).freeze
end

#schedule_workflow(workflow, cron_schedule, *input, **args) ⇒ Object

We don't support testing the actual cron schedules, but we will defer execution. You can simulate running these deferred with Temporal::Testing.execute_all_scheduled_workflows o Temporal::Testing.execute_scheduled_workflow, or assert against the cron schedule with Temporal::Testing.schedules.


24
25
26
27
28
29
30
# File 'lib/temporal/testing/temporal_override.rb', line 24

def schedule_workflow(workflow, cron_schedule, *input, **args)
  return super if Temporal::Testing.disabled?

  if Temporal::Testing.local?
    start_locally(workflow, cron_schedule, *input, **args)
  end
end

#start_workflow(workflow, *input, **args) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/temporal/testing/temporal_override.rb', line 11

def start_workflow(workflow, *input, **args)
  return super if Temporal::Testing.disabled?

  if Temporal::Testing.local?
    start_locally(workflow, nil, *input, **args)
  end
end