Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test helper functions like assert_triggered #16

Open
sevenseacat opened this issue Feb 21, 2024 · 0 comments
Open

Test helper functions like assert_triggered #16

sevenseacat opened this issue Feb 21, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@sevenseacat
Copy link
Contributor

When testing actions that can kick off background jobs, it would be nice to be able to have succinct and fine-grained assertions on exactly what jobs were fired.

Oban provides assert_enqueued, and that can be used eg.

# A job should be enqueued to make the meeting on Zoom
assert_enqueued(args: %{primary_key: %{id: appointment.id}}, queue: :zoom_api)

But nothing really more specific, given that worker modules are dynamically defined.

It would be great if assert_enqueued was wrapped in a way that if we had code like:

update :update do
  change AshOban.Changes.BuiltinChanges.run_oban_trigger(:create_zoom_meeting)
end

We could test it like:

{:ok, appointment} = Appointment.update(appointment, params)
assert_triggered(appointment, :create_zoom_meeting)
@sevenseacat sevenseacat added the enhancement New feature or request label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant