Reputation: 137
How can I run Oban jobs (I am using a Cron job plugin with Oban) on localhost so that I can see it is working?
My Oban's just run a query and then create a file at a location. I want to be able to test this on localhost or which ever correct method there is for testing this.
defmodule ObanJobOne do
def job(_) do
"""
some sql query
"""
|> IO.inspect
|> //do some mapping
|> //create file
end
end
How can I run ObanJobOne
so that I can see the results of the sql query with the IO.inspect
and also see the file that got created.
Upvotes: 2
Views: 1117
Reputation: 6872
Oban jobs are just modules. You can use iex -S mix
to test them locally:
YourWorker.perform(%Oban.Job{args: %{"id" => 1}})
If you want to test the queue itself, use:
%{id: 1}
|> YourWorker.new()
|> Oban.insert()
Oban also supports ExUnit
with Oban.Testing
.
Upvotes: 2