mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge pull request #534 from Verba/inline-push-bulk
Run .push_bulk calls inline in inline testing mode
This commit is contained in:
commit
babdab431e
3 changed files with 14 additions and 9 deletions
|
@ -65,13 +65,7 @@ module Sidekiq
|
|||
end.compact
|
||||
|
||||
pushed = false
|
||||
Sidekiq.redis do |conn|
|
||||
_, pushed = conn.multi do
|
||||
conn.sadd('queues', normed['queue'])
|
||||
conn.rpush("queue:#{normed['queue']}", payloads)
|
||||
end
|
||||
end
|
||||
|
||||
pushed = raw_push(normed, payloads)
|
||||
pushed ? payloads.size : nil
|
||||
end
|
||||
|
||||
|
|
|
@ -28,8 +28,11 @@ module Sidekiq
|
|||
#
|
||||
singleton_class.class_eval do
|
||||
alias_method :raw_push_old, :raw_push
|
||||
def raw_push(hash, _)
|
||||
hash['class'].constantize.new.perform(*Sidekiq.load_json(Sidekiq.dump_json(hash['args'])))
|
||||
def raw_push(normed, payload)
|
||||
Array.wrap(payload).each do |hash|
|
||||
normed['class'].constantize.new.perform(*Sidekiq.load_json(hash)['args'])
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,6 +80,14 @@ class TestInline < MiniTest::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
it 'stubs the push_bulk call when in testing mode' do
|
||||
assert Sidekiq::Client.push_bulk({'class' => InlineWorker, 'args' => [true, true]})
|
||||
|
||||
assert_raises InlineError do
|
||||
Sidekiq::Client.push_bulk({'class' => InlineWorker, 'args' => [true, false]})
|
||||
end
|
||||
end
|
||||
|
||||
it 'should relay parameters through json' do
|
||||
assert Sidekiq::Client.enqueue(InlineWorkerWithTimeParam, Time.now)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue