You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use Oban extensively and sometimes rely on Oban jobs to be inserted when another record is created or updated. For a given workflow to be tested, this may happen in multiple places, including as part of the test setups. The problem with the current test helpers, namely assert_enqueued and refute_enqueued is that they pick up any job that was enqueued up to that point, no matter if it was part of the test setup or actual code under testing.
Of course, we could add flags everywhere in our functions that disable enqueuing the job. But that would be changing the code just to cater to the way we (need to) test it.
Solution
Add two test helpers assert_enqueue and refute_enqueue that receive a function and detect only jobs that were (or were not) enqueued while running that function, similar to assert_raise/3.
@arnodirlam Your proposal makes a lot of sense, and I'm in favor of it. The only quirk is pattern matching on args, as that's currently done with a database query, but I'm sure we can work around that.
Is your feature request related to a problem?
We use Oban extensively and sometimes rely on Oban jobs to be inserted when another record is created or updated. For a given workflow to be tested, this may happen in multiple places, including as part of the test setups. The problem with the current test helpers, namely
assert_enqueued
andrefute_enqueued
is that they pick up any job that was enqueued up to that point, no matter if it was part of the test setup or actual code under testing.Of course, we could add flags everywhere in our functions that disable enqueuing the job. But that would be changing the code just to cater to the way we (need to) test it.
Solution
Add two test helpers
assert_enqueue
andrefute_enqueue
that receive a function and detect only jobs that were (or were not) enqueued while running that function, similar to assert_raise/3.For example:
Considerations
IMO, the helpers should ...
Hope that makes sense. Thanks a lot for the relentless work on this great library! ❤️
The text was updated successfully, but these errors were encountered: