B Getting: Add default implementation, delegate, prepare test support.
This commit is contained in:
parent
0c5cc51983
commit
c1402af293
|
@ -141,6 +141,8 @@
|
||||||
# https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects
|
# https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects
|
||||||
config :phoenix, :plug_init_mode, :runtime
|
config :phoenix, :plug_init_mode, :runtime
|
||||||
|
|
||||||
|
config :pleroma, :config_impl, Pleroma.UnstubbedConfigMock
|
||||||
|
|
||||||
if File.exists?("./config/test.secret.exs") do
|
if File.exists?("./config/test.secret.exs") do
|
||||||
import_config "test.secret.exs"
|
import_config "test.secret.exs"
|
||||||
else
|
else
|
||||||
|
|
|
@ -5,4 +5,11 @@
|
||||||
defmodule Pleroma.Config.Getting do
|
defmodule Pleroma.Config.Getting do
|
||||||
@callback get(any()) :: any()
|
@callback get(any()) :: any()
|
||||||
@callback get(any(), any()) :: any()
|
@callback get(any(), any()) :: any()
|
||||||
|
|
||||||
|
def get(key), do: get(key, nil)
|
||||||
|
def get(key, default), do: impl().get(key, default)
|
||||||
|
|
||||||
|
def impl() do
|
||||||
|
Application.get_env(:pleroma, :config_impl, Pleroma.Config)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,5 +26,6 @@
|
||||||
Mox.defmock(Pleroma.Web.FederatorMock, for: Pleroma.Web.Federator.Publishing)
|
Mox.defmock(Pleroma.Web.FederatorMock, for: Pleroma.Web.Federator.Publishing)
|
||||||
|
|
||||||
Mox.defmock(Pleroma.ConfigMock, for: Pleroma.Config.Getting)
|
Mox.defmock(Pleroma.ConfigMock, for: Pleroma.Config.Getting)
|
||||||
|
Mox.defmock(Pleroma.UnstubbedConfigMock, for: Pleroma.Config.Getting)
|
||||||
|
|
||||||
Mox.defmock(Pleroma.LoggerMock, for: Pleroma.Logging)
|
Mox.defmock(Pleroma.LoggerMock, for: Pleroma.Logging)
|
||||||
|
|
Loading…
Reference in New Issue