oban-bg / oban

💎 Robust job processing in Elixir, backed by modern PostgreSQL and SQLite3
https://oban.pro
Apache License 2.0
3.37k stars 313 forks source link

Add build_job/3 as new test helper #1147

Closed viniciussbs closed 2 months ago

viniciussbs commented 2 months ago

Is your feature request related to a problem? Please describe.

I have some jobs that have their IDs stored somewhere when they're performed - for specific business rules. I would like to test this behaviour using existing test helpers, but perform_job/3 only returns the result, not the job itself.

Describe the Solution You'd Like

Describe Alternatives You've Considered

  1. Make existing perform_job/3 return both the job and the result, but this would be a breaking change that can be avoided.
  2. Change return type of my jobs to also return their IDs.

Additional Context

I know we have with_testing_mode/2, but I believe simple helpers are more straightforward.

viniciussbs commented 2 months ago

I've only suggested this because it wouldn't add new code to be maintained. It would just expose something that already exists.

sorentwo commented 2 months ago

It's a good suggestion, and something I'm sure many people could have used in the past.

sorentwo commented 2 months ago

Done. This will be available in Oban v2.19

viniciussbs commented 2 months ago

Thank you so much!

AntoineAugusti commented 1 month ago

Thanks for this issue and the PR! We also need this change to test job broadcasting, having access to the job ID in tests is required.