1
0
Fork 0
mirror of https://github.com/endofunky/sidetiq.git synced 2022-11-09 13:53:30 -05:00
endofunky--sidetiq/test/helper.rb

44 lines
948 B
Ruby
Raw Normal View History

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'
# Keep the test output clean.
2013-03-11 10:23:49 -04:00
Sidetiq.logger = Logger.new(nil)
Dir[File.join(File.dirname(__FILE__), 'fixtures/**/*.rb')].each do |fixture|
require fixture
end
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
end