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

raise error upon empty queue

This commit is contained in:
awaw 2013-05-31 02:39:01 +08:00
parent ad4a0b9c93
commit 8e98314bc9
2 changed files with 10 additions and 0 deletions

View file

@ -1,5 +1,7 @@
module Sidekiq
class EmptyQueueError < RuntimeError; end
class Client
class << self
alias_method :raw_push_old, :raw_push
@ -90,6 +92,8 @@ module Sidekiq
# Pop out a single job and perform it
def perform_one
raise(EmptyQueueError,
"perform_one called with empty job queue") unless jobs.size > 0
job = jobs.shift
new.perform(*job['args'])
end

View file

@ -130,6 +130,12 @@ class TestTesting < Minitest::Test
DirectWorker.clear
end
it 'perform_one raise error upon empty queue' do
assert_raises Sidekiq::EmptyQueueError do
DirectWorker.perform_one
end
end
class FirstWorker
include Sidekiq::Worker
class_attribute :count