1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/test/test_scheduling.rb
Jason Staten b3249eb503 Handle Redis#zadd return value correctly
Redis#zadd will return a boolean value when only one item is added. This
was failing to be equal to 1, and caused any Sidekiq::Client::push
invocations with an 'at' value to return false, even if they
successfully were stored into redis.
2012-06-20 16:24:23 -06:00

33 lines
815 B
Ruby

require 'helper'
require 'sidekiq/scheduled'
class TestScheduling < MiniTest::Unit::TestCase
describe 'middleware' do
before do
@redis = MiniTest::Mock.new
# Ugh, this is terrible.
Sidekiq.instance_variable_set(:@redis, @redis)
def @redis.with; yield self; end
end
class ScheduledWorker
include Sidekiq::Worker
def perform(x)
end
end
it 'schedules a job via interval' do
@redis.expect :zadd, true, ['schedule', String, String]
assert_equal true, ScheduledWorker.perform_in(600, 'mike')
@redis.verify
end
it 'schedules a job via timestamp' do
@redis.expect :zadd, true, ['schedule', String, String]
assert_equal true, ScheduledWorker.perform_in(5.days.from_now, 'mike')
@redis.verify
end
end
end