ソケットが終了することをテストする方法を探しています。テスト対象のコードは、これを行います。Phoenixソケットが終了したことをテストするにはどうすればよいですか?
def handle_in("logout", _payload, socket) do
{:stop, :logout, socket |> assign(:user, nil)}
end
そして(http://elixir-lang.org/getting-started/try-catch-and-rescue.html#exitsから適応)私のテストコードは、この行います
test "logout terminates the socket", %{socket: socket} do
try do
push socket, "logout"
catch
huh -> IO.puts("Caught something #{IO.inspect huh}")
:exit, what -> IO.puts("Caught :exit #{IO.inspect what}")
end
assert_receive {:DOWN, monitor_ref, _, :normal}
end
を私はテストを実行したとき、私はこれを取得:
1) test logout without login terminates the socket (Main.AuthChannelTest)
test/channels/auth_channel_test.exs:47
** (EXIT from #PID<0.505.0>) :logout
.....09:06:41.139 [error] GenServer #PID<0.507.0> terminating
** (stop) :logout
を
どのようにする必要があります私はソケットの閉鎖をテストされますか?
OK、ありがとう。私は ''正常な ''が適切な理由だと判断したので、私は今のところ設定されていると思う。 – escouten