Sha256: 491b377d613c014feee2272c57ea445adf42820543bf7dd4d1430201aa33f4ad
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
require 'spec_helper' require 'sidekiq/api' require 'sidekiq/worker' require 'sidekiq_unique_jobs/server/middleware' require 'sidekiq_unique_jobs/client/middleware' require 'sidekiq_unique_jobs/sidekiq_unique_ext' RSpec.describe 'Sidekiq::Api' do before do Sidekiq.redis = REDIS Sidekiq.redis(&:flushdb) end let(:item) do { 'class' => JustAWorker, 'queue' => 'testqueue', 'args' => [foo: 'bar'] } end def unique_key SidekiqUniqueJobs::UniqueArgs.digest( 'class' => JustAWorker, 'queue' => 'testqueue', 'args' => [foo: 'bar'], 'at' => (Date.today + 1).to_time.to_i ) end def schedule_job JustAWorker.perform_in(60 * 60 * 3, foo: 'bar') end def perform_async JustAWorker.perform_async(foo: 'bar') end describe Sidekiq::SortedEntry::UniqueExtension, sidekiq_ver: '>= 3.1' do it 'deletes uniqueness lock on delete' do expect(schedule_job).to be_truthy Sidekiq::ScheduledSet.new.each(&:delete) Sidekiq.redis do |c| expect(c.exists(unique_key)).to be_falsy end expect(schedule_job).to be_truthy end end describe Sidekiq::Job::UniqueExtension do it 'deletes uniqueness lock on delete' do jid = perform_async Sidekiq::Queue.new('testqueue').find_job(jid).delete Sidekiq.redis do |c| expect(c.exists(unique_key)).to be_falsy end expect(true).to be_truthy end end describe Sidekiq::Queue::UniqueExtension do it 'deletes uniqueness locks on clear' do perform_async Sidekiq::Queue.new('testqueue').clear Sidekiq.redis do |c| expect(c.exists(unique_key)).to be_falsy end end end describe Sidekiq::JobSet::UniqueExtension, sidekiq_ver: '>= 3.1' do it 'deletes uniqueness locks on clear' do schedule_job Sidekiq::JobSet.new('schedule').clear Sidekiq.redis do |c| expect(c.exists(unique_key)).to be_falsy end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-unique-jobs-4.0.18 | spec/lib/sidekiq_unique_jobs/sidekiq_unique_ext_spec.rb |