-
Notifications
You must be signed in to change notification settings - Fork 122
Testing Sidekiq::Status correctly? #63
Comments
@nikhgupta have you solved this issue? |
It would also be good if we could test |
This would be somewhat involved...essentially creating an entire fake Sidekiq::Status::Storage
Not sure if this is worthwhile. Currently I get by by setting expectations on |
If you don't mind actually pushing jobs to redis during testing, I would recommend using the following: require 'sidekiq/testing'
Sidekiq::Testing.disable! # allows jobs to be pushed to redis. Use #enable! to reverse Or, simply not requiring Our own test suite functions by not including / disabling Sidekiq's testing mocks, and our spec_helper.rb file would be a great place to start if you're looking to do full integration tests. |
I am using Sidekiq::Status inside an app that relies heavily on the status reported by this gem, esp. since the status is displayed to the users of this application.
I found the current way of testing a bit brittle, since all it does is to mock the return status as
:complete
. I understand the fact thatinline
way of testing sidekiq will always give:complete
status. But, Sidekiq also hasSidekiq::Testing.fake!
, which when used should return status as per the job's actual status. That is, I should be able to do this:However, since Sidekiq does not run Server Middlewares with such tests, we can add:
So, I would like to know if this is a valid way to test this gem? And, if so, would you be willing to accept a PR? Also, I am still not sure how to test
nil
status with this, when the job expires after the given expiration time.The text was updated successfully, but these errors were encountered: