Sha256: 6f36b1b3fb7190bb91c9dd04883ed2eadadfdaf78eb8e48f0d5493506e3507d3

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

describe Sidekiq::QueueMetrics::JobDeathMiddleware do
  let(:redis_connection) { Redis.new }

  before(:all) do
    Sidekiq.redis = ConnectionPool.new { redis_connection }
  end

  before { redis_connection.flushall }

  context 'when retry_count key is not present' do
    it 'should call the job dead monitor' do
      expect_any_instance_of(Sidekiq::QueueMetrics::JobDeathMonitor).not_to receive(:monitor)

      subject.call(Class.new, {}, 'test_queue')
    end
  end

  context 'when retry_count key is greater than 0' do
    it 'should call the job dead monitor' do
      expect_any_instance_of(Sidekiq::QueueMetrics::JobDeathMonitor).not_to receive(:monitor)

      subject.call(Class.new, { 'retry_count' => 1 }, 'test_queue')
    end
  end

  context 'when retry_count key is 0' do
    it 'should call the job dead monitor' do
      expect_any_instance_of(Sidekiq::QueueMetrics::JobDeathMonitor).to receive(:monitor).with({
        'retry_count' => 0,
        'error_class' => 'StandardError'
      })

      subject.call(Class.new, {
        'retry_count' => 0,
        'error_class' => 'StandardError'
      }, 'test_queue')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekiq_queue_metrics-3.0.0 spec/lib/sidekiq_queue_metrics/job_death_middleware_spec.rb