live_beats/test/support/presence/presence_mock.ex

30 lines
623 B
Elixir
Raw Normal View History

2021-12-13 18:33:13 +00:00
defmodule Phoenix.Presence.Client.PresenceMock do
use GenServer
alias Phoenix.Presence.Client
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, opts[:id], opts)
end
@impl true
def init(id) do
{:ok, %{id: id}}
end
2021-12-15 18:40:37 +00:00
def track(client_pid, pid, topic, key, meta \\ %{}) do
GenServer.cast(pid, {:track, client_pid, topic, key, meta})
2021-12-13 18:33:13 +00:00
end
@impl true
def handle_info(:quit, state) do
{:stop, :normal, state}
end
@impl true
2021-12-15 18:40:37 +00:00
def handle_cast({:track, client_pid, topic, key, meta}, state) do
Client.track(client_pid, topic, key, meta)
2021-12-13 18:33:13 +00:00
{:noreply, state}
end
end