Oban.testing isn't working

Hey guys,
I’m testing this module but it’s not working,

defmodule MyApp.ErrorReporter do
  alias MyApp.Reportable

  def handle_event([:oban, :job, :exception], _, %{attempt: attempt, worker: worker} = meta, _) do
context = Map.take(meta.job, [:id, :args, :queue, :worker])

    if Reportable.reportable?(worker_struct, meta.job.attempt) do
       Logger.error("Error", attempt: attempt, error: meta.error, context: context)

I need to simulate this Logger in the test and then implement the exception of this error.

Workers aren’t structs by default. Are you using defstruct in your worker definition?

yes, followed that documentation and here is how struct:

Sorry, you’ll need to provide more context for me to help. Perhaps a test failure?

Hi @nowdev welcome. When you say something isn’t working, you need to show code that you are running. Please elaborate by showing your code, output, etc, so that help can be provided.

1 Like