Sha256: 37d6478fb745aeb29b7dcccfd4e0964a22c3607c3b1fef3e4879c2adb764bae4
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
require 'spec_helper' RSpec.describe SidekiqUniqueJobs::Lock::UntilAndWhileExecuting do let(:item) do { 'jid' => 'maaaahjid', 'queue' => 'dupsallowed', 'class' => 'UntilAndWhileExecuting', 'unique' => 'until_executed', 'args' => [1], } end let(:callback) { -> {} } subject { described_class.new(item) } describe '#execute' do before do subject.lock(:client) end let(:runtime_lock) { SidekiqUniqueJobs::Lock::WhileExecuting.new(item, nil) } it 'unlocks the unique key before yielding' do expect(SidekiqUniqueJobs::Lock::WhileExecuting) .to receive(:new).with(item, nil) .and_return(runtime_lock) expect(callback).to receive(:call) subject.execute(callback) do Sidekiq.redis do |c| expect(c.keys('uniquejobs:*').size).to eq(1) end 10.times { Sidekiq::Client.push(item) } Sidekiq.redis do |c| expect(c.keys('uniquejobs:*').size).to eq(2) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems