Support `cancelled` callback in `Oban.Testing.Pro.perform_callback/4`
Closed this issue · 1 comments
up2jj commented
Environment
- Oban Version: 1.3.5 Pro
- PostgreSQL Version: 13
- Elixir & Erlang/OTP Versions: 1.16.2, OTP: 26.2.5
Current Behavior
I defined batch worker with the handle_cancelled/1
callback:
@impl Batch
def handle_cancelled(%Job{meta: %{"batch_id" => batch_id}}) do
Logger.error("Some jobs were cancelled during import, batch_id: #{batch_id}")
:ok
end
https://oban.dev/docs/pro/1.3.5/Oban.Pro.Workers.Batch.html#c:handle_cancelled/1
I am trying to test callback behaviour with Oban.Testing.Pro.perform_callback/4
but cancelled
callback is not supported:
test "handle_cancelled/1" do
assert :ok = perform_callback(MyJob, :cancelled, %{batch_id: "batch_id"})
end
It gives:
Expected callback to be included in [:attempted, :completed, :discarded, :exhausted], got: :cancelled
.
Checks for other callbacks work fine.
Expected Behavior
Oban.Testing.Pro.perform_callback/4
should support cancelled
callback.
sorentwo commented
Thanks for the report. This is fixed on main and will be in the next patch release.