Sha256: 6d6dee82d302c5d491739ad33caefb6cbe825f9625f56b1e8316f2b7e0aa6d35
Contents?: true
Size: 1.84 KB
Versions: 3
Compression:
Stored size: 1.84 KB
Contents
require 'spec_helper' require 'sidekiq/api' require 'sidekiq/worker' require 'sidekiq_unique_jobs/middleware/server/unique_jobs' require 'sidekiq_unique_jobs/middleware/client/unique_jobs' require 'sidekiq_unique_jobs/sidekiq_unique_ext' class JustAWorker include Sidekiq::Worker sidekiq_options unique: true, queue: 'testqueue' def perform end end describe Sidekiq::Job::UniqueExtension do before do Sidekiq.redis = REDIS Sidekiq.redis(&:flushdb) end it 'deletes uniqueness lock on delete' do params = { foo: 'bar' } payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload('JustAWorker', 'testqueue', [params]) jid = JustAWorker.perform_async(foo: 'bar') queue = Sidekiq::Queue.new('testqueue') job = queue.find_job(jid) job.delete Sidekiq.redis do |c| expect(c.exists(payload_hash)).to be_falsy end end end describe Sidekiq::Queue::UniqueExtension do before do Sidekiq.redis = REDIS Sidekiq.redis(&:flushdb) end it 'deletes uniqueness locks on clear' do params = { foo: 'bar' } payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload('JustAWorker', 'testqueue', [params]) JustAWorker.perform_async(foo: 'bar') queue = Sidekiq::Queue.new('testqueue') queue.clear Sidekiq.redis do |c| expect(c.exists(payload_hash)).to be_falsy end end end describe Sidekiq::JobSet::UniqueExtension, sidekiq_ver: 3 do before do Sidekiq.redis = REDIS Sidekiq.redis(&:flushdb) end it 'deletes uniqueness locks on clear' do params = { foo: 'bar' } payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload('JustAWorker', 'testqueue', [params]) JustAWorker.perform_in(60 * 60 * 3, foo: 'bar') set = Sidekiq::JobSet.new('schedule') set.clear Sidekiq.redis do |c| expect(c.exists(payload_hash)).to be_falsy end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-unique-jobs-3.0.10 | spec/lib/sidekiq_unique_ext_spec.rb |
sidekiq-unique-jobs-3.0.9 | spec/lib/sidekiq_unique_ext_spec.rb |
sidekiq-unique-jobs-3.0.8 | spec/lib/sidekiq_unique_ext_spec.rb |