1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Verify errors

This commit is contained in:
Mike Perham 2015-10-07 09:08:47 -07:00
parent 26ac0e90e0
commit 3e90dc4304

View file

@ -72,6 +72,7 @@ class TestActors < Sidekiq::Test
end end
class Mgr class Mgr
attr_reader :latest_error
attr_reader :mutex attr_reader :mutex
attr_reader :cond attr_reader :cond
def initialize def initialize
@ -79,11 +80,13 @@ class TestActors < Sidekiq::Test
@cond = ::ConditionVariable.new @cond = ::ConditionVariable.new
end end
def processor_done(inst) def processor_done(inst)
@latest_error = nil
@mutex.synchronize do @mutex.synchronize do
@cond.signal @cond.signal
end end
end end
def processor_died(inst, err) def processor_died(inst, err)
@latest_error = err
@mutex.synchronize do @mutex.synchronize do
@cond.signal @cond.signal
end end
@ -131,6 +134,8 @@ class TestActors < Sidekiq::Test
sleep 0.001 sleep 0.001
assert_equal false, p.thread.status assert_equal false, p.thread.status
p.terminate(true) p.terminate(true)
refute_nil mgr.latest_error
assert_equal RuntimeError, mgr.latest_error.class
end end
it 'gracefully kills' do it 'gracefully kills' do
@ -151,6 +156,7 @@ class TestActors < Sidekiq::Test
b = $count b = $count
assert_equal a, b assert_equal a, b
assert_equal false, p.thread.status assert_equal false, p.thread.status
assert_nil mgr.latest_error
end end
end end
end end