Skip to content

Commit

Permalink
Added test for timeout reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
andshopify committed Jan 19, 2024
1 parent fb38fa3 commit 5fdcf29
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/unit/test_soft_timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ def test_extend_deadline
timeout&.finished
end

def test_reduce_deadline
called = []
timeout = SoftTimeout.request(2.5, -> (thread) { called << thread })
timeout.extend_deadline(-2)
sleep 1
assert_equal [Thread.current], called
assert_predicate timeout, :done?
ensure
timeout&.finished
end

def test_cancel
called = []
timeout = SoftTimeout.request(0.5, -> (thread) { called << thread })
Expand Down

0 comments on commit 5fdcf29

Please sign in to comment.