Skip to content

Commit 9ce9025

Browse files
Fix auto_time_skipping_disabled (#260)
1 parent 1d8b2c6 commit 9ce9025

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

temporalio/lib/temporalio/testing/workflow_environment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def auto_time_skipping_disabled(&)
322322
raise 'Block required' unless block_given?
323323
return super unless supports_time_skipping?
324324

325-
already_disabled = @auto_time_skipping
325+
already_disabled = !@auto_time_skipping
326326
@auto_time_skipping = false
327327
begin
328328
yield

temporalio/test/testing/workflow_environment_test.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,34 @@ def test_time_skipping_auto
5555
end
5656
end
5757

58+
def test_auto_time_skipping_disabled
59+
skip_if_not_x86!
60+
Temporalio::Testing::WorkflowEnvironment.start_time_skipping(logger: Logger.new($stdout)) do |env|
61+
worker = Temporalio::Worker.new(
62+
client: env.client,
63+
task_queue: "tq-#{SecureRandom.uuid}",
64+
workflows: [SlowWorkflow]
65+
)
66+
worker.run do
67+
# Check that timestamp is around now
68+
assert_in_delta(Time.now, env.current_time, 30.0)
69+
70+
# Run workflow
71+
handle = env.client.start_workflow(
72+
SlowWorkflow,
73+
id: "wf-#{SecureRandom.uuid}",
74+
task_queue: worker.task_queue
75+
)
76+
env.auto_time_skipping_disabled do
77+
handle.signal(SlowWorkflow.some_signal)
78+
end
79+
# Check that timestamp is now about two days from now
80+
assert_equal 'all done', handle.result
81+
assert_in_delta Time.now + SlowWorkflow::TWO_DAYS, env.current_time, 30.0
82+
end
83+
end
84+
end
85+
5886
def test_time_skipping_manual
5987
skip_if_not_x86!
6088
Temporalio::Testing::WorkflowEnvironment.start_time_skipping(logger: Logger.new($stdout)) do |env|

0 commit comments

Comments
 (0)