Sha256: 72a31c325b45cf57a3049a5198dbfc59b0311792d64bc537ffb68515d46b5591

Contents?: true

Size: 1023 Bytes

Versions: 10

Compression:

Stored size: 1023 Bytes

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 { subject.lock(:client) }
    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

10 entries across 10 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-4.0.17 spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb
sidekiq-unique-jobs-4.0.16 spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb
sidekiq-unique-jobs-4.0.15 spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb
sidekiq-unique-jobs-4.0.13 spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb
sidekiq-unique-jobs-4.0.12 spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb
sidekiq-unique-jobs-4.0.11 spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb
sidekiq-unique-jobs-4.0.10 spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb
sidekiq-unique-jobs-4.0.9 spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb
sidekiq-unique-jobs-4.0.8 spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb
sidekiq-unique-jobs-4.0.7 spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb