Skip to content

Commit

Permalink
Use configuration for tree consistency validations for dev and test e…
Browse files Browse the repository at this point in the history
…nvironments

NOTE: Mix env is not available in production
  • Loading branch information
electronicbites committed Sep 2, 2024
1 parent a00d0c1 commit 066eb69
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ config :radiator, RadiatorWeb.Endpoint,
# Enable dev routes for dashboard and mailbox
config :radiator, dev_routes: true

# Enable tree consistency validator: crashes when tree is not valid!
config :radiator, tree_consistency_validator: true

# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"

Expand Down
3 changes: 3 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ config :phoenix, :plug_init_mode, :runtime
# Enable helpful, but potentially expensive runtime checks
config :phoenix_live_view,
enable_expensive_runtime_checks: true

# Enable tree consistency validator: crashes when tree is not valid!
config :radiator, tree_consistency_validator: true
3 changes: 2 additions & 1 deletion lib/radiator/outline/dispatch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ defmodule Radiator.Outline.Dispatch do
end

def broadcast(event) do
if Mix.env() == :dev || Mix.env() == :test do
# if enabled validate tree and crash if tree got inconsistenc
if Application.get_env(:radiator, :tree_consistency_validator, false) do
:ok =
event
|> Event.episode_id()
Expand Down

0 comments on commit 066eb69

Please sign in to comment.