Replies: 2 comments 2 replies
-
|
To test batches, you'll need to use a GoodJob adapter (the GoodJob Inline adapter is intended to be usable in tests), not the Active Job Aside: You're seeing the I'm not very familiar with minitest patterns, but this is what I have in my RSpec projects; the intent being to use test setup to configure which adapter to use: # spec/support/active_job.rb
RSpec.configure do |config|
config.include ActiveJob::TestHelper
config.around do |example|
original_queue_adapter = ActiveJob::Base.queue_adapter
if example.metadata[:active_job]
ActiveJob::Base.queue_adapter = :test
example.run
clear_enqueued_jobs
clear_performed_jobs
elsif example.metadata[:good_job]
ActiveJob::Base.queue_adapter = :good_job # Inline mode is default in Rails.env.test?
example.run
else
ActiveJob::Base.queue_adapter = :inline
example.run
end
ensure
ActiveJob::Base.queue_adapter = original_queue_adapter
end
config.after do
GoodJob.capsule.shutdown
end
end |
Beta Was this translation helpful? Give feedback.
-
|
What's interesting is that even just trying to match this enqueued FinishJob, it keeps failing: assert_enqueued_with job: FinishJob, args: [GoodJob::BatchRecord.last.to_batch, {event: :finish}]This refuses to match it, even though the batch object is identical, and the event seems correct. 🤔 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using
:testadapter, Minitest, and Rails test helpers (good_job 4.8.2, rails 8.0.1). It's been working very well. Now I introduced a batch for the first time, like this:The tests for jobs being enqueued work well:
However, I noticed that the
FinishJobis enqueued alongside theNestedJobs. Is that intentional?The main question: How can I test that the
FinishJobwill be called at the end of NestedJobs, with the correct arguments, with this setup?Beta Was this translation helpful? Give feedback.
All reactions