FarmbotExt: Dont supervise anything in :test
parent
128ed8ec43
commit
9a5b927953
|
@ -1,6 +1,13 @@
|
|||
use Mix.Config
|
||||
|
||||
if Mix.env() == :test do
|
||||
config :farmbot_ext, FarmbotExt, children: []
|
||||
config :farmbot_ext, FarmbotExt.Bootstrap.Supervisor, children: []
|
||||
mapper = fn mod -> config :farmbot_ext, mod, children: [] end
|
||||
list = [
|
||||
FarmbotExt,
|
||||
FarmbotExt.AMQP.ChannelSupervisor,
|
||||
FarmbotExt.API.DirtyWorker.Supervisor,
|
||||
FarmbotExt.API.EagerLoader.Supervisor,
|
||||
FarmbotExt.Bootstrap.Supervisor,
|
||||
]
|
||||
Enum.map(list, mapper)
|
||||
end
|
||||
|
|
|
@ -19,17 +19,19 @@ defmodule FarmbotExt.AMQP.ChannelSupervisor do
|
|||
end
|
||||
|
||||
def init([token]) do
|
||||
jwt = JWT.decode!(token)
|
||||
Supervisor.init(children(JWT.decode!(token)), strategy: :one_for_one)
|
||||
end
|
||||
|
||||
children = [
|
||||
def children(jwt) do
|
||||
config = Application.get_env(:farmbot_ext, __MODULE__) || []
|
||||
|
||||
Keyword.get(config, :children, [
|
||||
{TelemetryChannel, [jwt: jwt]},
|
||||
{LogChannel, [jwt: jwt]},
|
||||
{PingPongChannel, [jwt: jwt]},
|
||||
{BotStateChannel, [jwt: jwt]},
|
||||
{AutoSyncChannel, [jwt: jwt]},
|
||||
{CeleryScriptChannel, [jwt: jwt]}
|
||||
]
|
||||
|
||||
Supervisor.init(children, strategy: :one_for_one)
|
||||
])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,14 +10,17 @@ defmodule FarmbotExt.AMQP.Supervisor do
|
|||
end
|
||||
|
||||
def init([]) do
|
||||
Supervisor.init(children(), strategy: :one_for_all)
|
||||
end
|
||||
|
||||
def children do
|
||||
token = get_config_value(:string, "authorization", "token")
|
||||
email = get_config_value(:string, "authorization", "email")
|
||||
config = Application.get_env(:farmbot_ext, __MODULE__) || []
|
||||
|
||||
children = [
|
||||
Keyword.get(config, :children, [
|
||||
{FarmbotExt.AMQP.ConnectionWorker, [token: token, email: email]},
|
||||
{FarmbotExt.AMQP.ChannelSupervisor, [token]}
|
||||
]
|
||||
|
||||
Supervisor.init(children, strategy: :one_for_all)
|
||||
])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,13 @@ defmodule FarmbotExt.API.DirtyWorker.Supervisor do
|
|||
|
||||
@impl Supervisor
|
||||
def init(_args) do
|
||||
children = [
|
||||
Supervisor.init(children(), strategy: :one_for_one)
|
||||
end
|
||||
|
||||
def children do
|
||||
config = Application.get_env(:farmbot_ext, __MODULE__) || []
|
||||
|
||||
Keyword.get(config, :children, [
|
||||
{DirtyWorker, Device},
|
||||
{DirtyWorker, DeviceCert},
|
||||
{DirtyWorker, FbosConfig},
|
||||
|
@ -50,8 +56,6 @@ defmodule FarmbotExt.API.DirtyWorker.Supervisor do
|
|||
{DirtyWorker, Sensor},
|
||||
{DirtyWorker, Sequence},
|
||||
{DirtyWorker, Tool}
|
||||
]
|
||||
|
||||
Supervisor.init(children, strategy: :one_for_one)
|
||||
])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,7 +39,13 @@ defmodule FarmbotExt.API.EagerLoader.Supervisor do
|
|||
|
||||
@impl Supervisor
|
||||
def init(_args) do
|
||||
children = [
|
||||
Supervisor.init(children(), strategy: :one_for_one)
|
||||
end
|
||||
|
||||
def children do
|
||||
config = Application.get_env(:farmbot_ext, __MODULE__) || []
|
||||
|
||||
Keyword.get(config, :children, [
|
||||
{EagerLoader, Device},
|
||||
{EagerLoader, FarmEvent},
|
||||
{EagerLoader, FarmwareEnv},
|
||||
|
@ -56,8 +62,6 @@ defmodule FarmbotExt.API.EagerLoader.Supervisor do
|
|||
{EagerLoader, Sensor},
|
||||
{EagerLoader, Sequence},
|
||||
{EagerLoader, Tool}
|
||||
]
|
||||
|
||||
Supervisor.init(children, strategy: :one_for_one)
|
||||
])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,7 @@ defmodule FarmbotExt.Bootstrap.Supervisor do
|
|||
|
||||
def children() do
|
||||
config = Application.get_env(:farmbot_ext, __MODULE__) || []
|
||||
|
||||
Keyword.get(config, :children, [
|
||||
FarmbotExt.API.EagerLoader.Supervisor,
|
||||
FarmbotExt.API.DirtyWorker.Supervisor,
|
||||
|
|
|
@ -32,35 +32,3 @@ defmodule Helpers do
|
|||
end
|
||||
end
|
||||
|
||||
defmodule Helpers.NamedProcess do
|
||||
@moduledoc """
|
||||
NOTE: Inspired by ex_venture test suite. Thanks! -RC
|
||||
|
||||
Register a globaly named process that fakes out a normally real process.
|
||||
|
||||
Any messages this process receives will forward them to the test process via `send`.
|
||||
"""
|
||||
|
||||
use GenServer
|
||||
|
||||
@doc """
|
||||
Link a new process to the test process
|
||||
|
||||
This takes place outside of the supervision tree, so the process does
|
||||
not hang around.
|
||||
"""
|
||||
def start_link(name) do
|
||||
GenServer.start_link(__MODULE__, [caller: self(), name: name], [name: {:global, name}])
|
||||
end
|
||||
|
||||
@impl true
|
||||
def init(state) do
|
||||
{:ok, Enum.into(state, %{})}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_cast(message, state) do
|
||||
send(state.caller, {state.name, {:cast, message}})
|
||||
{:noreply, state}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue