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:
parent
ad4a0b9c93
commit
8e98314bc9
2 changed files with 10 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
module Sidekiq
|
module Sidekiq
|
||||||
|
|
||||||
|
class EmptyQueueError < RuntimeError; end
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
class << self
|
class << self
|
||||||
alias_method :raw_push_old, :raw_push
|
alias_method :raw_push_old, :raw_push
|
||||||
|
@ -90,6 +92,8 @@ module Sidekiq
|
||||||
|
|
||||||
# Pop out a single job and perform it
|
# Pop out a single job and perform it
|
||||||
def perform_one
|
def perform_one
|
||||||
|
raise(EmptyQueueError,
|
||||||
|
"perform_one called with empty job queue") unless jobs.size > 0
|
||||||
job = jobs.shift
|
job = jobs.shift
|
||||||
new.perform(*job['args'])
|
new.perform(*job['args'])
|
||||||
end
|
end
|
||||||
|
|
|
@ -130,6 +130,12 @@ class TestTesting < Minitest::Test
|
||||||
DirectWorker.clear
|
DirectWorker.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'perform_one raise error upon empty queue' do
|
||||||
|
assert_raises Sidekiq::EmptyQueueError do
|
||||||
|
DirectWorker.perform_one
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class FirstWorker
|
class FirstWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
class_attribute :count
|
class_attribute :count
|
||||||
|
|
Loading…
Reference in a new issue