Skip to content

Commit

Permalink
Prevent duplicate subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cdpfeetfirst committed Sep 25, 2018
1 parent dd773fb commit d25a979
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/pub_sub_test.exs
Expand Up @@ -30,6 +30,15 @@ defmodule PubSubTest do
assert PubSub.subscribers(topic2) == [pid3]
end

test "duplicate subscriptions are ignored" do
[pid1] = spawn_multiple(1)

PubSub.subscribe(pid1, :topic)
PubSub.subscribe(pid1, :topic)

assert PubSub.subscribers(:topic) == [pid1]
end

test "processes can unsubscribe from topics" do
[pid1, pid2, pid3] = spawn_multiple(3)
{topic1, topic2} = {:erlang, :elixir}
Expand Down

0 comments on commit d25a979

Please sign in to comment.