Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
83 lines (63 sloc) 1.48 KB
dir = File.dirname(File.expand_path(__FILE__))
$LOAD_PATH.unshift dir + '/../lib'
$TESTING = true
require 'test/unit'
require 'rubygems'
require 'shoulda'
require 'mocha'
require 'resque/status'
require 'resque/job_with_status'
class Test::Unit::TestCase
end
#
# make sure we can run redis
#
if !system("which redis-server")
puts '', "** can't find `redis-server` in your path"
puts "** try running `sudo rake install`"
abort ''
end
#
# start our own redis when the tests start,
# kill it when they end
#
at_exit do
next if $!
if defined?(MiniTest)
exit_code = MiniTest::Unit.new.run(ARGV)
else
exit_code = Test::Unit::AutoRunner.run
end
pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0]
puts "Killing test redis server..."
`rm -f #{dir}/dump.rdb`
Process.kill("KILL", pid.to_i)
exit exit_code
end
puts "Starting redis for testing at localhost:9736..."
`redis-server #{dir}/redis-test.conf`
Resque.redis = 'localhost:9736'
Redisk.redis = 'localhost:9736'
#### Fixtures
class WorkingJob < Resque::JobWithStatus
def perform
total = options['num']
(1..total).each do |num|
at(num, total, "At #{num}")
end
end
end
class ErrorJob < Resque::JobWithStatus
def perform
raise "I'm a bad little job"
end
end
class KillableJob < Resque::JobWithStatus
def perform
Resque.redis.set("#{uuid}:iterations", 0)
100.times do |num|
Resque.redis.incr("#{uuid}:iterations")
at(num, 100, "At #{num} of 100")
end
end
end
Something went wrong with that request. Please try again.