Skip to content

Commit

Permalink
Add more test (Unhandled msgs & options verification)
Browse files Browse the repository at this point in the history
  • Loading branch information
alde103 committed Jun 2, 2021
1 parent 8ffdc6a commit 61ec638
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/daemon_test.exs
Expand Up @@ -77,6 +77,19 @@ defmodule DaemonTest do
assert capture_log(fun) =~ "echo says: hello"
end

test "daemon logs unhandled messages" do
fun = fn ->
{:ok, _pid} = start_supervised(daemon_spec("echo", ["hello"], name: UnhandledMsg))

send(UnhandledMsg, "this is an unhandled msg")

wait_for_close_check()
Logger.flush()
end

assert capture_log(fun) =~ "Unhandled message: \"this is an unhandled msg\""
end

test "daemon dispatch the message to msg_callback" do
fun = fn ->
{:ok, _pid} =
Expand Down
2 changes: 2 additions & 0 deletions test/options_test.exs
Expand Up @@ -75,6 +75,8 @@ defmodule MuonTrap.OptionsTest do
|> Map.get(:msg_callback)
|> Kernel.==(&inspect/1)
|> assert()

assert Map.get(Options.validate(:daemon, "echo", [], msg_callback: nil), :msg_callback) == nil
end

test "common commands basically work" do
Expand Down

0 comments on commit 61ec638

Please sign in to comment.