             "/maybe" when retries < 5 -> {:error, :econnrefused}
             "/maybe" -> {:ok, env}
             "/nope" -> {:error, :econnrefused}
+            "/retry_status" -> {:ok, %{status: 500}}
           end
 
         {response, retries + 1}

  defmodule Client do
    use Tesla

    plug Tesla.Middleware.Retry, delay: 10, max_retries: 10

    adapter LaggyAdapter
  end

  setup do
    {:ok, _} = LaggyAdapter.start_link()

    assert {:error, :econnrefused} = Client.get("/nope")
  end

  test "use custom retry determination function" do
    assert {:ok, %{status: 500}} = ClientWithShouldRetryFunction.get("/retry_status")
  end

  defmodule DefunctClient do
    use Tesla

