don't start presence client on tests

This commit is contained in:
Berenice Medel Sánchez 2021-12-14 12:30:55 -06:00 committed by Chris McCord
parent 028c619047
commit 0bde8f40d6
3 changed files with 8 additions and 6 deletions

View file

@ -58,8 +58,6 @@ config :logger, :console,
# Use Jason for JSON parsing in Phoenix # Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason config :phoenix, :json_library, Jason
config :live_beats, :presence_client, LiveBeats.PresenceClient
# Import environment specific config. This must remain at the bottom # Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above. # of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs" import_config "#{config_env()}.exs"

View file

@ -31,5 +31,3 @@ config :logger, level: :warn
# Initialize plugs at runtime for faster test compilation # Initialize plugs at runtime for faster test compilation
config :phoenix, :plug_init_mode, :runtime config :phoenix, :plug_init_mode, :runtime
config :live_beats, :presence_client, Phoenix.Presence.Client.Mock

View file

@ -23,8 +23,8 @@ defmodule LiveBeats.Application do
LiveBeatsWeb.Endpoint, LiveBeatsWeb.Endpoint,
# Start a worker by calling: LiveBeats.Worker.start_link(arg) # Start a worker by calling: LiveBeats.Worker.start_link(arg)
# {LiveBeats.Worker, arg} # {LiveBeats.Worker, arg}
{Phoenix.Presence.Client, client: Application.get_env(:live_beats, :presence_client), pubsub: LiveBeats.PubSub, presence: LiveBeatsWeb.Presence}
] ] ++ start_presence_client(Mix.env)
# See https://hexdocs.pm/elixir/Supervisor.html # See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options # for other strategies and supported options
@ -39,4 +39,10 @@ defmodule LiveBeats.Application do
LiveBeatsWeb.Endpoint.config_change(changed, removed) LiveBeatsWeb.Endpoint.config_change(changed, removed)
:ok :ok
end end
defp start_presence_client(:test), do: []
defp start_presence_client(_) do
[{Phoenix.Presence.Client, client: LiveBeats.PresenceClient, pubsub: LiveBeats.PubSub, presence: LiveBeatsWeb.Presence, name: PresenceClient}]
end
end end