Skip to content

Commit

Permalink
Do not run supervisor children in test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
meequrox committed May 7, 2024
1 parent bdcfcab commit 408a650
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
2 changes: 2 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ config(:double_gis_monitor,
ecto_repos: [DoubleGisMonitor.Db.Repo]
)

config(:double_gis_monitor, :env, config_env())

config(:telegex, caller_adapter: {HTTPoison, [recv_timeout: 5 * 1000]})

# TODO: document all :double_gis_monitor options
Expand Down
32 changes: 20 additions & 12 deletions lib/double_gis_monitor/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,26 @@ defmodule DoubleGisMonitor.Application do
def start(_type, _args) do
Logger.info("App started, cwd: #{File.cwd!()}")

# TODO: Worker to run pipeline every $interval seconds
# {:ok, a} = DoubleGisMonitor.Pipeline.Fetch.call()
# {:ok, b} = DoubleGisMonitor.Pipeline.Process.call(a)
# {:ok, c} = DoubleGisMonitor.Pipeline.Dispatch.call(b)

children = [
DoubleGisMonitor.Db.Repo,
DoubleGisMonitor.Bot.Telegram
# DoubleGisMonitor.Worker.Poller
]

# TODO: Do not run children in test env
children =
case Application.fetch_env!(:double_gis_monitor, :env) do
:test ->
Logger.info("Using test environment. Do not add supervisor children.")

[]

other ->
Logger.info("Using #{other} environment. Adding supervisor children.")

[
DoubleGisMonitor.Db.Repo,
DoubleGisMonitor.Bot.Telegram
# DoubleGisMonitor.Worker.Poller
# TODO: Worker to run pipeline every $interval seconds
# {:ok, a} = DoubleGisMonitor.Pipeline.Fetch.call()
# {:ok, b} = DoubleGisMonitor.Pipeline.Process.call(a)
# {:ok, c} = DoubleGisMonitor.Pipeline.Dispatch.call(b)
]
end

opts = [strategy: :one_for_one, name: __MODULE__.Supervisor]
Supervisor.start_link(children, opts)
Expand Down
2 changes: 1 addition & 1 deletion test/double_gis_monitor_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule DoubleGisMonitorTest do
doctest DoubleGisMonitor

test "Dummy event building" do
e = %DoubleGisMonitor.Event{}
e = %DoubleGisMonitor.Db.Event{}
assert(e.uuid == nil)
end
end

0 comments on commit 408a650

Please sign in to comment.