sidekiq-throttled icon indicating copy to clipboard operation
sidekiq-throttled copied to clipboard

Rspec testing! How to do it ??

Open RichardsonWTR opened this issue 2 years ago • 1 comments

Given this situation:

# config/initializers/sidekiq.rb file
Sidekiq::Throttled::Registry.add(
  :my_throttle,
  concurrency: { limit: 50 }
)

# app/jobs/my_job.rb  file
class MyJob
  include Sidekiq::Worker
  include Sidekiq::Throttled::Worker
  sidekiq_throttle_as :my_throttle
end

How can I write tests in Rspec that assures:

  • The MyJob class has the expected throttle
  • The throttle has the expected value (in this case, 50)
  • The throttle is being used (when I push a job, make sure that the available jobs to be run is equals 49 in this case)

I've tried some things but still no luck. Any help will be useful.

Related #62

RichardsonWTR avatar Mar 31 '22 15:03 RichardsonWTR

Re:

  • The MyJob class has the expected throttle
  • The throttle has the expected value (in this case, 50)

We will need to add rspec matchers to simplify this task.


Re:

  • The throttle is being used (when I push a job, make sure that the available jobs to be run is equals 49 in this case)

I don't see a feasible way for such testing

ixti avatar Apr 16 '23 02:04 ixti