2013-02-08 07:54:32 -05:00
|
|
|
if ENV["COVERAGE"]
|
|
|
|
require 'simplecov'
|
|
|
|
SimpleCov.start { add_filter "/test/" }
|
|
|
|
end
|
2013-02-01 07:26:17 -05:00
|
|
|
|
2013-01-31 12:42:19 -05:00
|
|
|
require 'minitest/autorun'
|
|
|
|
require 'mocha/setup'
|
2013-02-01 07:26:17 -05:00
|
|
|
require 'rack/test'
|
|
|
|
|
|
|
|
require 'sidekiq'
|
2013-01-31 12:42:19 -05:00
|
|
|
require 'sidekiq/testing'
|
|
|
|
|
2013-02-01 07:26:17 -05:00
|
|
|
require 'sidetiq'
|
|
|
|
require 'sidetiq/web'
|
|
|
|
|
2013-03-11 07:00:55 -04:00
|
|
|
# Keep the test output clean.
|
2013-03-11 10:23:49 -04:00
|
|
|
Sidetiq.logger = Logger.new(nil)
|
2013-02-01 11:53:34 -05:00
|
|
|
|
2013-03-11 07:00:55 -04:00
|
|
|
Dir[File.join(File.dirname(__FILE__), 'fixtures/**/*.rb')].each do |fixture|
|
|
|
|
require fixture
|
|
|
|
end
|
|
|
|
|
2013-02-01 11:53:34 -05:00
|
|
|
class Sidetiq::TestCase < MiniTest::Unit::TestCase
|
|
|
|
def setup
|
|
|
|
Sidekiq.redis { |r| r.flushall }
|
|
|
|
end
|
2013-02-04 05:13:02 -05:00
|
|
|
|
|
|
|
def clock
|
|
|
|
@clock ||= Sidetiq::Clock.instance
|
|
|
|
end
|
2013-03-11 09:01:37 -04:00
|
|
|
|
|
|
|
# Blatantly stolen from Sidekiq's test suite.
|
|
|
|
def add_retry(worker = 'SimpleWorker', jid = 'bob', at = Time.now.to_f)
|
|
|
|
payload = Sidekiq.dump_json('class' => worker,
|
|
|
|
'args' => [], 'queue' => 'default', 'jid' => jid,
|
|
|
|
'retry_count' => 2, 'failed_at' => Time.now.utc)
|
|
|
|
|
|
|
|
Sidekiq.redis do |conn|
|
|
|
|
conn.zadd('retry', at.to_s, payload)
|
|
|
|
end
|
|
|
|
end
|
2013-02-01 11:53:34 -05:00
|
|
|
end
|
|
|
|
|