Sha256: 81d996301af683e39b066bd7ee1ad828d589ebabb2fe5ba8013fb50c5f6f978b
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'spec_helper' RSpec.describe Sidekiq::LimitFetch do before :each do Sidekiq.redis do |it| it.del 'queue:queue1' it.lpush 'queue:queue1', 'task1' it.lpush 'queue:queue1', 'task2' it.expire 'queue:queue1', 30 end end subject { described_class.new options } let(:options) {{ queues: queues, limits: limits }} let(:queues) { %w(queue1 queue1 queue2 queue2) } let(:limits) {{ 'queue1' => 1, 'queue2' => 2 }} it 'should acquire lock on queue for execution' do work = subject.retrieve_work expect(work.queue_name).to eq 'queue1' expect(work.message).to eq 'task1' expect(Sidekiq::Queue['queue1'].busy).to eq 1 expect(Sidekiq::Queue['queue2'].busy).to eq 0 expect(subject.retrieve_work).not_to be work.requeue expect(Sidekiq::Queue['queue1'].busy).to eq 0 expect(Sidekiq::Queue['queue2'].busy).to eq 0 work = subject.retrieve_work expect(work.message).to eq 'task1' expect(Sidekiq::Queue['queue1'].busy).to eq 1 expect(Sidekiq::Queue['queue2'].busy).to eq 0 expect(subject.retrieve_work).not_to be work.acknowledge expect(Sidekiq::Queue['queue1'].busy).to eq 0 expect(Sidekiq::Queue['queue2'].busy).to eq 0 work = subject.retrieve_work expect(work.message).to eq 'task2' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-limit_fetch-2.4.2 | spec/sidekiq/limit_fetch_spec.rb |