diff --git a/farmbot_ext/config/config.exs b/farmbot_ext/config/config.exs index d19826fd..350fc6cf 100644 --- a/farmbot_ext/config/config.exs +++ b/farmbot_ext/config/config.exs @@ -8,6 +8,10 @@ config :farmbot_firmware, FarmbotFirmware, reset: FarmbotFirmware.NullReset config :farmbot_celery_script, FarmbotCeleryScript.SysCalls, sys_calls: FarmbotCeleryScript.SysCalls.Stubs +if Mix.env() == :test do + import_config "test.exs" +end + import_config "ecto.exs" import_config "farmbot_core.exs" import_config "lagger.exs" diff --git a/farmbot_ext/config/test.exs b/farmbot_ext/config/test.exs new file mode 100644 index 00000000..03407f4a --- /dev/null +++ b/farmbot_ext/config/test.exs @@ -0,0 +1,3 @@ +use Mix.Config + +config :farmbot_ext, FarmbotExt.Bootstrap.Supervisor, children: [] diff --git a/farmbot_ext/lib/farmbot_ext/amqp/auto_sync_channel.ex b/farmbot_ext/lib/farmbot_ext/amqp/auto_sync_channel.ex index aa3e946c..dc7409d5 100644 --- a/farmbot_ext/lib/farmbot_ext/amqp/auto_sync_channel.ex +++ b/farmbot_ext/lib/farmbot_ext/amqp/auto_sync_channel.ex @@ -136,7 +136,8 @@ defmodule FarmbotExt.AMQP.AutoSyncChannel do id = data["id"] || String.to_integer(id_str) _ = handle_asset(asset_kind, id, body) - _ -> "" + _ -> + "" # Logger.info("ignoring route: #{key}") end diff --git a/farmbot_ext/lib/farmbot_ext/bootstrap/supervisor.ex b/farmbot_ext/lib/farmbot_ext/bootstrap/supervisor.ex index b875c436..7fa79d16 100644 --- a/farmbot_ext/lib/farmbot_ext/bootstrap/supervisor.ex +++ b/farmbot_ext/lib/farmbot_ext/bootstrap/supervisor.ex @@ -1,6 +1,6 @@ defmodule FarmbotExt.Bootstrap.Supervisor do @moduledoc """ - Supervisor responsible for starting all + Supervisor responsible for starting all the tasks and processes that require authentication. """ use Supervisor @@ -12,7 +12,14 @@ defmodule FarmbotExt.Bootstrap.Supervisor do @impl Supervisor def init([]) do - children = [ + Supervisor.init(children(), strategy: :one_for_one) + end + + # This only exists because I was getting too many crashed + # supervisor reports in the test suite (distraction from + # real test failures). + def children do + default = [ FarmbotExt.API.EagerLoader.Supervisor, FarmbotExt.API.DirtyWorker.Supervisor, FarmbotExt.AMQP.Supervisor, @@ -20,7 +27,7 @@ defmodule FarmbotExt.Bootstrap.Supervisor do FarmbotExt.Bootstrap.DropPasswordTask ] - opts = [strategy: :one_for_one] - Supervisor.init(children, opts) + config = Application.get_env(:farmbot_ext, __MODULE__) || [] + Keyword.get(config, :children, default) end end diff --git a/farmbot_ext/test/farmbot_ext/amqp/auto_sync_channel_test.exs b/farmbot_ext/test/farmbot_ext/amqp/auto_sync_channel_test.exs index d8b9c5d7..a412bbcd 100644 --- a/farmbot_ext/test/farmbot_ext/amqp/auto_sync_channel_test.exs +++ b/farmbot_ext/test/farmbot_ext/amqp/auto_sync_channel_test.exs @@ -1,7 +1,4 @@ defmodule AutoSyncChannelTest do - - import ExUnit.CaptureIO - alias FarmbotExt.AMQP.AutoSyncChannel use ExUnit.Case, async: true @@ -12,6 +9,7 @@ defmodule AutoSyncChannelTest do API.Preloader, AMQP.ConnectionWorker } + setup :verify_on_exit! setup :set_mimic_global diff --git a/farmbot_ext/test/farmbot_ext/amqp/bot_state_channel_test.exs b/farmbot_ext/test/farmbot_ext/amqp/bot_state_channel_test.exs index 5ce5466c..d03cf239 100644 --- a/farmbot_ext/test/farmbot_ext/amqp/bot_state_channel_test.exs +++ b/farmbot_ext/test/farmbot_ext/amqp/bot_state_channel_test.exs @@ -15,9 +15,11 @@ defmodule FarmbotExt.AMQP.BotStateChannelTest do test "terminate" do expected = "Disconnected from BotState channel: \"foo\"" expect(AMQP.Channel, :close, 1, fn "fake_chan_" -> :ok end) + expect(FarmbotCore.LogExecutor, :execute, 1, fn log -> assert log.message == expected end) + FarmbotExt.AMQP.BotStateChannel.terminate("foo", %FakeState{}) end end diff --git a/farmbot_ext/test/farmbot_ext/api/view_test.exs b/farmbot_ext/test/farmbot_ext/api/view_test.exs index 49cb5f34..b3c4b179 100644 --- a/farmbot_ext/test/farmbot_ext/api/view_test.exs +++ b/farmbot_ext/test/farmbot_ext/api/view_test.exs @@ -1,13 +1,12 @@ defmodule FarmbotExt.API.ViewTest do - use ExUnit.Case + use ExUnit.Case - def render(%{ok: :ok}) do - :yep - end - - test "render/2" do - result = FarmbotExt.API.View.render(__MODULE__, %{ok: :ok}) - assert :yep == result - end + def render(%{ok: :ok}) do + :yep end - \ No newline at end of file + + test "render/2" do + result = FarmbotExt.API.View.render(__MODULE__, %{ok: :ok}) + assert :yep == result + end +end