Testing helpers for Fleet background jobs.
Provides utilities to run worker jobs synchronously and assert on enqueued jobs without starting a full Broadway pipeline.
Example
defmodule MyApp.MyWorkerTest do
use ExUnit.Case, async: true
use Fleet.Testing, repo: MyApp.Repo
test "runs the worker" do
assert :ok = perform_job(MyApp.Workers.SendEmail, %{"to" => "alice@example.com"})
assert_enqueued(
worker: MyApp.Workers.FollowUp,
args: %{"to" => "alice@example.com"}
)
end
end
Summary
Functions
Returns all enqueued jobs matching the given filter criteria (:worker, :args, :queue).
Queries both the database (Ecto Sandbox aware) and in-memory test tracker.
Asserts that a job matching the given criteria was enqueued.
Clears all recorded enqueued jobs.
Ensures the testing ETS tracker table exists.
Runs a worker synchronously with the provided arguments or Fleet.Job struct.
Returns the worker's perform result (:ok, {:ok, val}, {:error, reason}, {:snooze, seconds}, {:cancel, reason}).
Asserts that no job matching the given criteria was enqueued.
Functions
Returns all enqueued jobs matching the given filter criteria (:worker, :args, :queue).
Queries both the database (Ecto Sandbox aware) and in-memory test tracker.
Asserts that a job matching the given criteria was enqueued.
Clears all recorded enqueued jobs.
Ensures the testing ETS tracker table exists.
Runs a worker synchronously with the provided arguments or Fleet.Job struct.
Returns the worker's perform result (:ok, {:ok, val}, {:error, reason}, {:snooze, seconds}, {:cancel, reason}).
Asserts that no job matching the given criteria was enqueued.