25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-10-31 15:21:38 +01:00
xmpp.chapril.org-ejabberd/test/elixir-config/ejabberd_logger.exs

50 lines
1.2 KiB
Elixir
Raw Normal View History

defmodule Ejabberd.Config.EjabberdLoggerTest do
use ExUnit.Case
import ExUnit.CaptureIO
alias Ejabberd.Config
alias Ejabberd.Config.Store
alias Ejabberd.Config.Validation
alias Ejabberd.Config.EjabberdLogger
setup_all do
pid = Process.whereis(Ejabberd.Config.Store)
unless pid != nil and Process.alive?(pid) do
Store.start_link
File.cd("test/elixir-config/shared")
config_file_path = File.cwd! <> "/ejabberd_for_validation.exs"
Config.init(config_file_path)
end
{:ok, %{}}
end
test "outputs correctly when attr is not supported" do
error_msg = "[ WARN ] Annotation @attr_not_supported is not supported.\n"
2018-06-20 11:27:44 +02:00
[_mod_configure, mod_time] = Store.get(:modules)
fun = fn ->
mod_time
|> Validation.validate
|> EjabberdLogger.log_errors
end
assert capture_io(fun) == error_msg
end
test "outputs correctly when dependency is not found" do
error_msg = "[ WARN ] Module :mod_adhoc was not found, but is required as a dependency.\n"
2018-06-20 11:27:44 +02:00
[mod_configure, _mod_time] = Store.get(:modules)
fun = fn ->
mod_configure
|> Validation.validate
|> EjabberdLogger.log_errors
end
assert capture_io(fun) == error_msg
end
end