A job in sidekiq, upon exception, will be put on the retry queue.
Because of that, and because the task is run asynchronously, MyWorker.perform_async(...)
can never throw an exception generated in the task code.
In testing, however, an exception that occurs in the task does not cause the task to be put in the retry queue. The exception bubbles up out of perform_async
.
So what happens in tests is something that cannot possible occur when running the code.
What, then, is the best way to test code that triggers jobs that can fail and be put on the retry queue?
Note that the following seems to have no effect in testing:
Sidekiq.default_worker_options = { :retry => true}
Aucun commentaire:
Enregistrer un commentaire