   defp workers(queue) do
     Honeydew.status(queue) |> Map.get(:workers) |> Map.keys
   end
+
+  defp assert_worker_restarted(queue, worker) do
+    [new_worker] = workers(queue)
+
+    assert worker != new_worker
+  end
+
 end

    assert [worker] == workers(queue)
  end

  test "workers restart when a linked process terminates abnormally" do
    queue = :erlang.unique_integer

    :ok = Honeydew.start_queue(queue)
    :ok = Honeydew.start_workers(queue, Stateless, num: 1)

    [worker] = workers(queue)

    fn -> spawn_link(fn -> raise "intentional crash" end) end |> Honeydew.async(queue)
    Process.sleep(200)

    assert [worker] != workers(queue)
  end

  test "workers restart after a job crashes" do
    queue = :erlang.unique_integer

    :ok = Honeydew.start_queue(queue)
    :ok = Honeydew.start_workers(queue, Stateless, num: 1)

    [worker] = workers(queue)

    fn -> raise "intentional crash" end |> Honeydew.async(queue)
    Process.sleep(100)

    [new_worker] = workers(queue)

    assert worker != new_worker
  end

  test "stateful workers reinitialize by default" do

  @moduletag :capture_log

  setup :restart_honeydew

  defmodule EchoingFailureMode do
    alias Honeydew.Job
    alias Honeydew.Queue
    @behaviour Honeydew.FailureMode

    def validate_args!([test_pid]) when is_pid(test_pid), do: :ok

    def handle_failure(%Job{queue: queue, from: from} = job, reason, [test_pid]) do
      send test_pid, {:job_failed, reason}

      # tell the queue that that job can be removed.
      queue
      |> Honeydew.get_queue
      |> Queue.ack(job)

      # send the error to the awaiting process, if necessary
      with {owner, _ref} <- from,
        do: send(owner, %{job | result: {:error, reason}})
    end

    def await_job_failure_reason do
      assert_receive({:job_failed, reason})
      reason
    end
  end

  test "queues/0 + stop_queue/1" do
    assert Enum.empty?(Honeydew.queues)
