tarakan/test/support/github_bulk_stubs.ex
Maxfield Luke af6077b9c3
All checks were successful
CI and deploy / Test (push) Successful in 4m52s
CI and deploy / Deploy production (push) Successful in 23s
Initial commit on Forgejo
Fresh repository history for elektrine/tarakan hosted at
https://git.elektrine.com/elektrine/tarakan.
2026-07-29 04:43:40 -04:00

22 lines
667 B
Elixir

defmodule Tarakan.GitHubBulkStub do
@moduledoc """
Bulk-lookup stub. Tests script responses per node id with
`put_response/2`; unscripted ids resolve to `nil` (node gone).
"""
@behaviour Tarakan.GitHubBulkClient
def put_response(node_id, response) do
Process.put({__MODULE__, node_id}, response)
end
@impl true
def fetch_repositories_by_node_ids(node_ids) when is_list(node_ids) do
case Process.get({__MODULE__, :batch_error}) do
nil -> {:ok, Enum.map(node_ids, &Process.get({__MODULE__, &1}))}
reason -> {:error, reason}
end
end
def fail_batches_with(reason), do: Process.put({__MODULE__, :batch_error}, reason)
end