Skip to content
Browse files

make tests compatible with new sidekiq internals

  • Loading branch information...
1 parent a95c941 commit 543a0a8f0337eb51e658cd441a726d118c249756 @mhfs committed Jan 18, 2013
Showing with 17 additions and 18 deletions.
  1. +16 −18 test/middleware_test.rb
  2. +1 −0 test/test_helper.rb
View
34 test/middleware_test.rb
@@ -35,38 +35,38 @@ def perform(args)
end
it 'records all failures by default' do
- msg = create_message('class' => MockWorker.to_s, 'args' => ['myarg'])
+ msg = create_work('class' => MockWorker.to_s, 'args' => ['myarg'])
assert_equal 0, failures_count
assert_raises TestException do
- @processor.process(msg, 'default')
+ @processor.process(msg)
end
assert_equal 1, failures_count
assert_equal 1, $invokes
end
it 'records all failures if explicitly told to' do
- msg = create_message('class' => MockWorker.to_s, 'args' => ['myarg'], 'failures' => true)
+ msg = create_work('class' => MockWorker.to_s, 'args' => ['myarg'], 'failures' => true)
assert_equal 0, failures_count
assert_raises TestException do
- @processor.process(msg, 'default')
+ @processor.process(msg)
end
assert_equal 1, failures_count
assert_equal 1, $invokes
end
it "doesn't record failure if failures disabled" do
- msg = create_message('class' => MockWorker.to_s, 'args' => ['myarg'], 'failures' => false)
+ msg = create_work('class' => MockWorker.to_s, 'args' => ['myarg'], 'failures' => false)
assert_equal 0, failures_count
assert_raises TestException do
- @processor.process(msg, 'default')
+ @processor.process(msg)
end
assert_equal 0, failures_count
@@ -76,12 +76,12 @@ def perform(args)
it "doesn't record failure if going to be retired again and configured to track exhaustion by default" do
Sidekiq.failures_default_mode = :exhausted
- msg = create_message('class' => MockWorker.to_s, 'args' => ['myarg'] )
+ msg = create_work('class' => MockWorker.to_s, 'args' => ['myarg'] )
assert_equal 0, failures_count
assert_raises TestException do
- @processor.process(msg, 'default')
+ @processor.process(msg)
end
assert_equal 0, failures_count
@@ -90,25 +90,25 @@ def perform(args)
it "doesn't record failure if going to be retired again and configured to track exhaustion" do
- msg = create_message('class' => MockWorker.to_s, 'args' => ['myarg'], 'failures' => 'exhausted')
+ msg = create_work('class' => MockWorker.to_s, 'args' => ['myarg'], 'failures' => 'exhausted')
assert_equal 0, failures_count
assert_raises TestException do
- @processor.process(msg, 'default')
+ @processor.process(msg)
end
assert_equal 0, failures_count
assert_equal 1, $invokes
end
it "records failure if failing last retry and configured to track exhaustion" do
- msg = create_message('class' => MockWorker.to_s, 'args' => ['myarg'], 'retry_count' => 24, 'failures' => 'exhausted')
+ msg = create_work('class' => MockWorker.to_s, 'args' => ['myarg'], 'retry_count' => 24, 'failures' => 'exhausted')
assert_equal 0, failures_count
assert_raises TestException do
- @processor.process(msg, 'default')
+ @processor.process(msg)
end
assert_equal 1, failures_count
@@ -118,26 +118,24 @@ def perform(args)
it "records failure if failing last retry and configured to track exhaustion by default" do
Sidekiq.failures_default_mode = 'exhausted'
- msg = create_message('class' => MockWorker.to_s, 'args' => ['myarg'], 'retry_count' => 24)
+ msg = create_work('class' => MockWorker.to_s, 'args' => ['myarg'], 'retry_count' => 24)
assert_equal 0, failures_count
assert_raises TestException do
- @processor.process(msg, 'default')
+ @processor.process(msg)
end
assert_equal 1, failures_count
assert_equal 1, $invokes
end
-
-
def failures_count
Sidekiq.redis { |conn|conn.llen('failed') } || 0
end
- def create_message(params)
- Sidekiq.dump_json(params)
+ def create_work(msg)
+ Sidekiq::BasicFetch::UnitOfWork.new('default', Sidekiq.dump_json(msg))
end
end
end
View
1 test/test_helper.rb
@@ -17,6 +17,7 @@ def blank?
require "sidekiq"
require "sidekiq-failures"
require "sidekiq/processor"
+require "sidekiq/fetch"
Celluloid.logger = nil
Sidekiq.logger.level = Logger::ERROR

0 comments on commit 543a0a8

Please sign in to comment.
Something went wrong with that request. Please try again.