24 lines
850 B
Elixir
24 lines
850 B
Elixir
defmodule Aprsme.SignalHandlerTest do
|
|
use ExUnit.Case, async: true
|
|
|
|
alias Aprsme.SignalHandler
|
|
|
|
describe "handle_info/2" do
|
|
test "ignores unrecognized messages without changing state" do
|
|
state = %{some: :state}
|
|
assert SignalHandler.handle_info(:random, state) == {:noreply, state}
|
|
assert SignalHandler.handle_info({:other, "msg"}, state) == {:noreply, state}
|
|
end
|
|
|
|
# We can't safely exercise the :sigterm clause here — it calls
|
|
# Aprsme.ShutdownHandler.shutdown() which would actually shut the app down.
|
|
end
|
|
|
|
describe "init/1" do
|
|
test "installs a SIGTERM handler and returns an empty state" do
|
|
# :os.set_signal is process-global but calling it a second time with
|
|
# :handle is idempotent at the VM level. Safe to exercise.
|
|
assert {:ok, %{}} = SignalHandler.init([])
|
|
end
|
|
end
|
|
end
|