Sha256: 691b3cb807749467463c60c6ddd2f1e82eae23705f3dc707b0ffecf5829a7223
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require 'spec_helper' RSpec.describe SidekiqUniqueJobs::Scripts::AcquireLock do let(:redis_pool) { nil } let(:jid) { 'abcdefab' } let(:unique_key) { 'uniquejobs:123asdasd2134' } let(:max_lock_time) { 1 } describe '.execute' do subject { instance_double(described_class) } it 'delegates to instance' do expect(described_class).to receive(:new) .with(redis_pool, unique_key, jid, max_lock_time) .and_return(subject) expect(subject).to receive(:execute).and_return(true) described_class.execute(redis_pool, unique_key, jid, max_lock_time) end end describe '#execute' do context 'when job is unique' do def execute(myjid = jid, key = unique_key, max_lock = max_lock_time) described_class.execute( redis_pool, key, myjid, max_lock ) end specify { expect(execute(jid, unique_key, max_lock_time)).to eq(true) } specify do expect(execute(jid, unique_key, max_lock_time)).to eq(true) expect(SidekiqUniqueJobs) .to have_key(unique_key) .for_seconds(max_lock_time) .with_value('abcdefab') sleep 0.5 expect(execute).to eq(true) end context 'when a unique_key exists for another jid' do before { expect(execute(jid, unique_key, 10)).to eq(true) } specify { expect(execute('anotherjid', unique_key, 5)).to eq(false) } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-unique-jobs-5.0.1 | spec/lib/sidekiq_unique_jobs/scripts/acquire_lock_spec.rb |