sidekiq-throttled
sidekiq-throttled copied to clipboard
Rspec testing! How to do it ??
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
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