Sha256: 497d7acdf34986adb186f3d0d64c80731b05f93b1ab47fe833e688f1bb022877
Contents?: true
Size: 1.86 KB
Versions: 4
Compression:
Stored size: 1.86 KB
Contents
describe Sidekiq::QueueMetrics::JobDeathMonitor do describe '#call' do let(:job) {{'queue' => 'mailer_queue'}} let(:exception) {double('exception')} let(:monitor) {Sidekiq::QueueMetrics::JobDeathMonitor.proc} context 'when stats does not exist' do it 'should create stats key and add stats of queue' do expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(nil) expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with({mailer_queue: {failed: 1}}.to_json) monitor.call(job) end end context 'when stats exists' do it 'should create a new queue when it does not exist' do existing_stats = {mailer_queue: {failed: 1}}.to_json expected_stats = {mailer_queue: {failed: 1}, job_queue: {failed: 1}}.to_json expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(existing_stats) expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with(expected_stats) monitor.call({'queue' => 'job_queue'}) end it 'should update existing queue' do existing_stats = {mailer_queue: {failed: 1}}.to_json expected_stats = {mailer_queue: {failed: 2}}.to_json expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(existing_stats) expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with(expected_stats) monitor.call(job) end it 'should create failed counter when other counters exists' do existing_stats = {mailer_queue: {processed: 1}}.to_json expected_stats = {mailer_queue: {processed: 1, failed: 1}}.to_json expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(existing_stats) expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with(expected_stats) monitor.call(job) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems