mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Upgrade to Minitest 5
This commit is contained in:
parent
beaec4422f
commit
4679c95f49
19 changed files with 47 additions and 44 deletions
|
@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
|
|||
gem.add_dependency 'multi_json'
|
||||
gem.add_development_dependency 'sinatra'
|
||||
gem.add_development_dependency 'slim'
|
||||
gem.add_development_dependency 'minitest'
|
||||
gem.add_development_dependency 'minitest', '~> 5'
|
||||
gem.add_development_dependency 'rake'
|
||||
gem.add_development_dependency 'actionmailer'
|
||||
gem.add_development_dependency 'activerecord'
|
||||
|
|
|
@ -17,9 +17,8 @@ begin
|
|||
rescue LoadError
|
||||
end
|
||||
|
||||
require 'minitest/unit'
|
||||
require 'minitest/autorun'
|
||||
require 'minitest/emoji'
|
||||
require 'minitest/pride'
|
||||
|
||||
require 'sidekiq'
|
||||
require 'sidekiq/util'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'helper'
|
||||
|
||||
class TestApi < MiniTest::Unit::TestCase
|
||||
class TestApi < Minitest::Test
|
||||
describe "stats" do
|
||||
before do
|
||||
Sidekiq.redis {|c| c.flushdb }
|
||||
|
|
|
@ -11,7 +11,7 @@ def cli.valid?
|
|||
!@code
|
||||
end
|
||||
|
||||
class TestCli < MiniTest::Unit::TestCase
|
||||
class TestCli < Minitest::Test
|
||||
describe 'with cli' do
|
||||
|
||||
before do
|
||||
|
|
|
@ -2,10 +2,10 @@ require 'helper'
|
|||
require 'sidekiq/client'
|
||||
require 'sidekiq/worker'
|
||||
|
||||
class TestClient < MiniTest::Unit::TestCase
|
||||
class TestClient < Minitest::Test
|
||||
describe 'with mock redis' do
|
||||
before do
|
||||
@redis = MiniTest::Mock.new
|
||||
@redis = Minitest::Mock.new
|
||||
def @redis.multi; [yield] * 2 if block_given?; end
|
||||
def @redis.set(*); true; end
|
||||
def @redis.sadd(*); true; end
|
||||
|
@ -22,6 +22,10 @@ class TestClient < MiniTest::Unit::TestCase
|
|||
Sidekiq.instance_variable_set(:@redis, @redis)
|
||||
end
|
||||
|
||||
after do
|
||||
Sidekiq.instance_variable_set(:@redis, REDIS)
|
||||
end
|
||||
|
||||
it 'raises ArgumentError with invalid params' do
|
||||
assert_raises ArgumentError do
|
||||
Sidekiq::Client.push('foo', 1)
|
||||
|
|
|
@ -17,7 +17,7 @@ class Component
|
|||
end
|
||||
end
|
||||
|
||||
class TestExceptionHandler < MiniTest::Unit::TestCase
|
||||
class TestExceptionHandler < Minitest::Test
|
||||
describe "with mock logger" do
|
||||
before do
|
||||
@old_logger = Sidekiq.logger
|
||||
|
@ -41,7 +41,7 @@ class TestExceptionHandler < MiniTest::Unit::TestCase
|
|||
|
||||
describe "with fake Airbrake" do
|
||||
before do
|
||||
::Airbrake = MiniTest::Mock.new
|
||||
::Airbrake = Minitest::Mock.new
|
||||
end
|
||||
|
||||
after do
|
||||
|
@ -57,7 +57,7 @@ class TestExceptionHandler < MiniTest::Unit::TestCase
|
|||
|
||||
describe "with fake Honeybadger" do
|
||||
before do
|
||||
::Honeybadger = MiniTest::Mock.new
|
||||
::Honeybadger = Minitest::Mock.new
|
||||
end
|
||||
|
||||
after do
|
||||
|
@ -73,7 +73,7 @@ class TestExceptionHandler < MiniTest::Unit::TestCase
|
|||
|
||||
describe "with fake ExceptionNotifier" do
|
||||
before do
|
||||
::ExceptionNotifier = MiniTest::Mock.new
|
||||
::ExceptionNotifier = Minitest::Mock.new
|
||||
end
|
||||
|
||||
after do
|
||||
|
@ -100,9 +100,9 @@ class TestExceptionHandler < MiniTest::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
::Exceptional::Config = MiniTest::Mock.new
|
||||
::Exceptional::Remote = MiniTest::Mock.new
|
||||
::Exceptional::ExceptionData = MiniTest::Mock.new
|
||||
::Exceptional::Config = Minitest::Mock.new
|
||||
::Exceptional::Remote = Minitest::Mock.new
|
||||
::Exceptional::ExceptionData = Minitest::Mock.new
|
||||
end
|
||||
|
||||
after do
|
||||
|
|
|
@ -8,7 +8,7 @@ require 'sidekiq/rails'
|
|||
|
||||
Sidekiq.hook_rails!
|
||||
|
||||
class TestExtensions < MiniTest::Unit::TestCase
|
||||
class TestExtensions < Minitest::Test
|
||||
describe 'sidekiq extensions' do
|
||||
before do
|
||||
Sidekiq.redis = REDIS
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'helper'
|
||||
require 'sidekiq/fetch'
|
||||
|
||||
class TestFetcher < MiniTest::Unit::TestCase
|
||||
class TestFetcher < Minitest::Test
|
||||
describe 'fetcher' do
|
||||
before do
|
||||
Sidekiq.redis = { :namespace => 'fuzzy' }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'helper'
|
||||
require 'sidekiq/manager'
|
||||
|
||||
class TestManager < MiniTest::Unit::TestCase
|
||||
class TestManager < Minitest::Test
|
||||
|
||||
describe 'manager' do
|
||||
it 'creates N processor instances' do
|
||||
|
@ -15,9 +15,9 @@ class TestManager < MiniTest::Unit::TestCase
|
|||
mgr = Sidekiq::Manager.new(options)
|
||||
count = options[:concurrency]
|
||||
|
||||
fetch_mock = MiniTest::Mock.new
|
||||
fetch_mock = Minitest::Mock.new
|
||||
count.times { fetch_mock.expect(:fetch, nil, []) }
|
||||
async_mock = MiniTest::Mock.new
|
||||
async_mock = Minitest::Mock.new
|
||||
count.times { async_mock.expect(:async, fetch_mock, []) }
|
||||
mgr.fetcher = async_mock
|
||||
mgr.start
|
||||
|
@ -27,8 +27,8 @@ class TestManager < MiniTest::Unit::TestCase
|
|||
end
|
||||
|
||||
it 'assigns work to a processor' do
|
||||
uow = MiniTest::Mock.new
|
||||
processor = MiniTest::Mock.new
|
||||
uow = Minitest::Mock.new
|
||||
processor = Minitest::Mock.new
|
||||
processor.expect(:async, processor, [])
|
||||
processor.expect(:process, nil, [uow])
|
||||
|
||||
|
@ -41,7 +41,7 @@ class TestManager < MiniTest::Unit::TestCase
|
|||
end
|
||||
|
||||
it 'requeues work if stopping' do
|
||||
uow = MiniTest::Mock.new
|
||||
uow = Minitest::Mock.new
|
||||
uow.expect(:requeue, nil, [])
|
||||
|
||||
mgr = Sidekiq::Manager.new(options)
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'helper'
|
|||
require 'sidekiq/middleware/chain'
|
||||
require 'sidekiq/processor'
|
||||
|
||||
class TestMiddleware < MiniTest::Unit::TestCase
|
||||
class TestMiddleware < Minitest::Test
|
||||
describe 'middleware chain' do
|
||||
before do
|
||||
$errors = []
|
||||
|
@ -78,9 +78,9 @@ class TestMiddleware < MiniTest::Unit::TestCase
|
|||
chain.insert_after AnotherCustomMiddleware, YetAnotherCustomMiddleware, '3', $recorder
|
||||
end
|
||||
|
||||
boss = MiniTest::Mock.new
|
||||
boss = Minitest::Mock.new
|
||||
processor = Sidekiq::Processor.new(boss)
|
||||
actor = MiniTest::Mock.new
|
||||
actor = Minitest::Mock.new
|
||||
actor.expect(:processor_done, nil, [processor])
|
||||
boss.expect(:async, actor, [])
|
||||
processor.process(Sidekiq::BasicFetch::UnitOfWork.new('queue:default', msg))
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
require 'helper'
|
||||
require 'sidekiq/processor'
|
||||
|
||||
class TestProcessor < MiniTest::Unit::TestCase
|
||||
class TestProcessor < Minitest::Test
|
||||
TestException = Class.new(StandardError)
|
||||
TEST_EXCEPTION = TestException.new("kerboom!")
|
||||
|
||||
describe 'with mock setup' do
|
||||
before do
|
||||
$invokes = 0
|
||||
@boss = MiniTest::Mock.new
|
||||
@boss = Minitest::Mock.new
|
||||
@processor = ::Sidekiq::Processor.new(@boss)
|
||||
Celluloid.logger = nil
|
||||
Sidekiq.redis = REDIS
|
||||
|
@ -29,7 +29,7 @@ class TestProcessor < MiniTest::Unit::TestCase
|
|||
|
||||
it 'processes as expected' do
|
||||
msg = Sidekiq.dump_json({ 'class' => MockWorker.to_s, 'args' => ['myarg'] })
|
||||
actor = MiniTest::Mock.new
|
||||
actor = Minitest::Mock.new
|
||||
actor.expect(:processor_done, nil, [@processor])
|
||||
@boss.expect(:async, actor, [])
|
||||
@processor.process(work(msg))
|
||||
|
@ -65,7 +65,7 @@ class TestProcessor < MiniTest::Unit::TestCase
|
|||
msg = { 'class' => MockWorker.to_s, 'args' => [['myarg']] }
|
||||
msgstr = Sidekiq.dump_json(msg)
|
||||
processor = ::Sidekiq::Processor.new(@boss)
|
||||
actor = MiniTest::Mock.new
|
||||
actor = Minitest::Mock.new
|
||||
actor.expect(:processor_done, nil, [processor])
|
||||
@boss.expect(:async, actor, [])
|
||||
processor.process(work(msgstr))
|
||||
|
@ -80,7 +80,7 @@ class TestProcessor < MiniTest::Unit::TestCase
|
|||
describe 'when successful' do
|
||||
def successful_job
|
||||
msg = Sidekiq.dump_json({ 'class' => MockWorker.to_s, 'args' => ['myarg'] })
|
||||
actor = MiniTest::Mock.new
|
||||
actor = Minitest::Mock.new
|
||||
actor.expect(:processor_done, nil, [@processor])
|
||||
@boss.expect(:async, actor, [])
|
||||
@processor.process(work(msg))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'helper'
|
||||
require 'sidekiq/redis_connection'
|
||||
|
||||
class TestRedisConnection < MiniTest::Unit::TestCase
|
||||
class TestRedisConnection < Minitest::Test
|
||||
|
||||
describe ".create" do
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ require 'helper'
|
|||
require 'sidekiq/scheduled'
|
||||
require 'sidekiq/middleware/server/retry_jobs'
|
||||
|
||||
class TestRetry < MiniTest::Unit::TestCase
|
||||
class TestRetry < Minitest::Test
|
||||
describe 'middleware' do
|
||||
before do
|
||||
@redis = MiniTest::Mock.new
|
||||
@redis = Minitest::Mock.new
|
||||
# Ugh, this is terrible.
|
||||
Sidekiq.instance_variable_set(:@redis, @redis)
|
||||
|
||||
|
@ -150,7 +150,7 @@ class TestRetry < MiniTest::Unit::TestCase
|
|||
raise "kerblammo!"
|
||||
end
|
||||
end
|
||||
# MiniTest can't assert that a method call did NOT happen!?
|
||||
# Minitest can't assert that a method call did NOT happen!?
|
||||
assert_raises(MockExpectationError) { @redis.verify }
|
||||
end
|
||||
|
||||
|
@ -164,12 +164,12 @@ class TestRetry < MiniTest::Unit::TestCase
|
|||
raise "kerblammo!"
|
||||
end
|
||||
end
|
||||
# MiniTest can't assert that a method call did NOT happen!?
|
||||
# Minitest can't assert that a method call did NOT happen!?
|
||||
assert_raises(MockExpectationError) { @redis.verify }
|
||||
end
|
||||
|
||||
describe "retry exhaustion" do
|
||||
let(:worker){ MiniTest::Mock.new }
|
||||
let(:worker){ Minitest::Mock.new }
|
||||
let(:handler){ Sidekiq::Middleware::Server::RetryJobs.new }
|
||||
let(:msg){ {"class"=>"Bob", "args"=>[1, 2, "foo"], "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>Time.now.utc, "retry"=>3, "retry_count"=>3} }
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'helper'
|
||||
require 'sidekiq/scheduled'
|
||||
|
||||
class TestScheduled < MiniTest::Unit::TestCase
|
||||
class TestScheduled < Minitest::Test
|
||||
class ScheduledWorker
|
||||
include Sidekiq::Worker
|
||||
def perform(x)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'helper'
|
||||
require 'sidekiq/scheduled'
|
||||
|
||||
class TestScheduling < MiniTest::Unit::TestCase
|
||||
class TestScheduling < Minitest::Test
|
||||
describe 'middleware' do
|
||||
before do
|
||||
@redis = MiniTest::Mock.new
|
||||
@redis = Minitest::Mock.new
|
||||
# Ugh, this is terrible.
|
||||
Sidekiq.instance_variable_set(:@redis, @redis)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# encoding: utf-8
|
||||
require 'helper'
|
||||
|
||||
class TestSidekiq < MiniTest::Unit::TestCase
|
||||
class TestSidekiq < Minitest::Test
|
||||
describe 'json processing' do
|
||||
it 'loads json' do
|
||||
assert_equal ({"foo" => "bar"}), Sidekiq.load_json("{\"foo\":\"bar\"}")
|
||||
|
@ -14,7 +14,7 @@ class TestSidekiq < MiniTest::Unit::TestCase
|
|||
|
||||
describe "redis connection" do
|
||||
it "returns error without creating a connection if block is not given" do
|
||||
mock = MiniTest::Mock.new
|
||||
mock = Minitest::Mock.new
|
||||
mock.expect :create, nil #Sidekiq::RedisConnection, create
|
||||
assert_raises(ArgumentError) {
|
||||
Sidekiq.redis
|
||||
|
|
|
@ -9,7 +9,7 @@ require 'sidekiq/extensions/active_record'
|
|||
|
||||
Sidekiq.hook_rails!
|
||||
|
||||
class TestTesting < MiniTest::Unit::TestCase
|
||||
class TestTesting < Minitest::Test
|
||||
describe 'sidekiq testing' do
|
||||
class PerformError < RuntimeError; end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ require 'sidekiq/extensions/active_record'
|
|||
|
||||
Sidekiq.hook_rails!
|
||||
|
||||
class TestInline < MiniTest::Unit::TestCase
|
||||
class TestInline < Minitest::Test
|
||||
describe 'sidekiq inline testing' do
|
||||
class InlineError < RuntimeError; end
|
||||
class ParameterIsNotString < RuntimeError; end
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'sidekiq'
|
|||
require 'sidekiq/web'
|
||||
require 'rack/test'
|
||||
|
||||
class TestWeb < MiniTest::Unit::TestCase
|
||||
class TestWeb < Minitest::Test
|
||||
describe 'sidekiq web' do
|
||||
include Rack::Test::Methods
|
||||
|
||||
|
|
Loading…
Reference in a new issue