Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidekiq tests failed when sidekiq-unique-jobs is used #24

Closed
salimane opened this issue Oct 22, 2013 · 2 comments
Closed

Sidekiq tests failed when sidekiq-unique-jobs is used #24

salimane opened this issue Oct 22, 2013 · 2 comments

Comments

@salimane
Copy link

My sidekiq tests with Sidekiq::Testing.fake! were passing until I've added sidekiq-unique-jobs and enabling it in my worker. All other tests are passing except line 19 and 20. Here is my test case :

class MyWorker
  include Sidekiq::Worker
  sidekiq_options :queue => :working, :retry => 1, :backtrace => 10
  sidekiq_options :unique => true

  sidekiq_retries_exhausted do |msg|
    Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
  end

  def perform(param)
    puts param
  end
end
require "spec_helper"

describe MyWorker do

    context "as a resque worker" do
        it "reponds to #perform" do
            MyWorker.new.should respond_to(:perform)
        end
    end

    it { should be_processed_in :working }
    it { should be_retryable 1 }
    it { should be_unique }

    it "enqueue a job" do
        param = 'work'
        expect(MyWorker).to have_enqueued_jobs(0)
        MyWorker.perform_async(param)
        expect(MyWorker).to have_enqueued_jobs(1)
        expect(MyWorker).to have_enqueued_job(param)
    end

    it "performs a job" do
        MyWorker.new.perform('chocolate').should be_true
    end
end
Failures:

  1) MyWorker enqueue a job
     Failure/Error: expect(MyWorker).to have_enqueued_jobs(1)
       expected MyWorker to have 1 enqueued job but got 0
     # ./spec/workers/my_worker_spec.rb:19:in `block (2 levels) in <top (required)>'
@lefty313
Copy link

I noticed same error in my workers with unique: true option

@mhenrixon
Copy link
Owner

Think this is related to #18 and #25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants