25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-04 15:36:57 +01:00
xmpp.chapril.org-ejabberd/test/elixir-config/ejabberd_logger.exs
gabrielgatu 803270fc6b
Support for Elixir configuration file #1208
Contribution for Google Summer of code 2016 by Gabriel Gatu
2016-09-08 11:37:14 +02:00

50 lines
1.2 KiB
Elixir

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"
[_mod_irc, _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"
[_mod_irc, 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