I’m working with Oban Pro’s new structured jobs feature, and I noticed that some tests using assert_enqueued
broke, specifically because of the args
.
I’m overriding the new/2
function so I can enqueue structs, so something like this works:
assert {:ok, %{}} = perform_job(MyStructuredJob, my_struct)
But the following does not because my_struct
(an Ecto struct) does not implement the Jason.Encoder
protocol:
assert_enqueued worker: MyStructuredJob,
args: my_struct,
queue: :my_queue
I get a Protocol.UndefinedError
. I could manually map my_struct
to a map of args
with string keys, but that defeats the purpose of wanting wall-off the knowledge of how the struct is processed/enqueued. Is there some way around this?