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

Added tests for perform_in_queue method on worker and enqueue_at on client

This commit is contained in:
Niels Kristian 2012-08-21 11:02:07 +02:00
parent 5ceec56b12
commit 6e2e34f013
3 changed files with 22 additions and 7 deletions

View file

@ -32,11 +32,6 @@ module Sidekiq
new.perform(*Sidekiq.load_json(Sidekiq.dump_json(args)))
true
end
alias_method :perform_in_queue_old, :perform_in_queue
def perform_in_queue(queue, *args)
new.perform(*Sidekiq.load_json(Sidekiq.dump_json(args)))
true
end
end
end
end

View file

@ -38,8 +38,7 @@ module Sidekiq
def perform_in_queue(queue, *args)
client_push('queue' => queue, 'class' => self, 'args' => args)
end
alias_method :perform_at_queue, :perform_in_queue
def perform_in(interval, *args)
int = interval.to_f
ts = (int < 1_000_000_000 ? Time.now.to_f + int : int)

View file

@ -69,6 +69,27 @@ class TestClient < MiniTest::Unit::TestCase
@redis.verify
end
it 'handles perform_in_queue' do
@redis.expect :rpush, 1, ['queue:custom_queue', String]
pushed = MyWorker.perform_in_queue(:custom_queue, 1, 2)
assert pushed
@redis.verify
end
it 'handles perform_in_queue on failure' do
@redis.expect :rpush, nil, ['queue:custom_queue', String]
pushed = MyWorker.perform_in_queue(:custom_queue, 1, 2)
refute pushed
@redis.verify
end
it 'enqueues messages to redis' do
@redis.expect :rpush, 1, ['queue:custom_queue', String]
pushed = Sidekiq::Client.enqueue_to(:custom_queue, MyWorker, 1, 2)
assert pushed
@redis.verify
end
class QueuedWorker
include Sidekiq::Worker
sidekiq_options :queue => :flimflam, :timeout => 1