diff options
author | Michal Muskala <michal@muskala.eu> | 2016-05-13 20:51:08 +0200 |
---|---|---|
committer | Michal Muskala <michal@muskala.eu> | 2016-05-13 21:25:14 +0200 |
commit | 01c4c42e117636cdba2d5278c851fbe7a3b39bc0 (patch) | |
tree | a8a6bbf1f15715e982c7d7c5aade7ac5593dc6f2 /test | |
parent | Merge pull request #43 from Annwenn/master (diff) |
Monitor owner of the connection
The connection process should monitor the process that started it
and die with the same reason that the owner process did.
This should solve the issue of zombie connections laying around
after the processes that started them die.
Diffstat (limited to 'test')
-rw-r--r-- | test/client_test.exs | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/test/client_test.exs b/test/client_test.exs index 6cff0b7..b7277b6 100644 --- a/test/client_test.exs +++ b/test/client_test.exs @@ -1,11 +1,30 @@ defmodule ExIrc.ClientTest do use ExUnit.Case - test "start multiple clients" do - {:ok, pid} = ExIrc.start_client! - {:ok, pid2} = ExIrc.start_client! + assert {:ok, pid} = ExIrc.start_client! + assert {:ok, pid2} = ExIrc.start_client! assert pid != pid2 end + test "client dies if owner process dies" do + test_pid = self() + + pid = spawn_link(fn -> + assert {:ok, pid} = ExIrc.start_client! + send(test_pid, {:client, pid}) + receive do + :stop -> :ok + end + end) + + client_pid = receive do + {:client, pid} -> pid + end + + assert Process.alive?(client_pid) + send(pid, :stop) + :timer.sleep(1) + refute Process.alive?(client_pid) + end end |