mirror of
https://github.com/deanpcmad/sidekiq-limit_fetch.git
synced 2022-11-09 13:54:36 -05:00
More tests
This commit is contained in:
parent
795fe952d1
commit
2ba307a539
1 changed files with 35 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
require 'sidekiq/limit_fetch'
|
||||
|
||||
describe Sidekiq::LimitFetch do
|
||||
before(:each) do
|
||||
before :each do
|
||||
Sidekiq.redis do |it|
|
||||
it.del 'queue:example'
|
||||
it.rpush 'queue:example', 'task'
|
||||
|
@ -29,7 +29,39 @@ describe Sidekiq::LimitFetch do
|
|||
|
||||
it 'should retrieve limited queues' do
|
||||
fetcher = new_fetcher strict: true, limits: { 'example' => 2 }
|
||||
2.times { queues(fetcher).should == %w(queue:example queue:example2) }
|
||||
queues(fetcher).should == %w(queue:example2)
|
||||
queues = -> { fetcher.available_queues }
|
||||
|
||||
queues1 = queues.call
|
||||
queues2 = queues.call
|
||||
queues1.should have(2).items
|
||||
queues2.should have(2).items
|
||||
queues.call.should have(1).items
|
||||
|
||||
queues1.each(&:release)
|
||||
queues.call.should have(2).items
|
||||
queues.call.should have(1).items
|
||||
|
||||
queues2.each(&:release)
|
||||
queues.call.should have(2).items
|
||||
queues.call.should have(1).items
|
||||
end
|
||||
|
||||
it 'should acquire lock on queue for excecution' do
|
||||
fetcher = new_fetcher limits: { 'example' => 1, 'example2' => 1 }
|
||||
work = fetcher.retrieve_work
|
||||
work.message.should == 'task'
|
||||
work.queue.should == 'queue:example'
|
||||
work.queue_name.should == 'example'
|
||||
|
||||
queues = fetcher.available_queues
|
||||
queues.should have(1).item
|
||||
queues.each(&:release)
|
||||
|
||||
work.requeue
|
||||
work = fetcher.retrieve_work
|
||||
work.message.should == 'task'
|
||||
work.acknowledge
|
||||
|
||||
fetcher.available_queues.should have(2).items
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue