Lines Matching refs:topic
28 {:ok, topic: to_string(config.test)}
41 assert DefaultPresence.fetch(config.topic, presences) == presences
45 assert MyPresence.list(config.topic) == %{}
46 assert MyPresence.list(%Phoenix.Socket{topic: config.topic}) == %{}
47 assert {:ok, _} = MyPresence.track(self(), config.topic, "u1", %{name: "u1"})
49 MyPresence.list(config.topic)
51 MyPresence.list(%Phoenix.Socket{topic: config.topic})
55 assert {:ok, _} = MyPresence.track(self(), config.topic, 1, %{name: "u1"})
57 MyPresence.list(config.topic)
61 %{topic: topic} = config do
64 Phoenix.PubSub.subscribe(config.pubsub, topic)
66 DefaultPresence.track(pid, topic, "u1", %{name: "u1"})
68 assert_receive %Broadcast{topic: ^topic, event: "presence_diff", payload: %{
73 DefaultPresence.list(topic)
76 assert_receive %Broadcast{topic: ^topic, event: "presence_diff", payload: %{
80 assert DefaultPresence.list(topic) == %{}
84 %{topic: topic} = config do
87 Phoenix.PubSub.subscribe(config.pubsub, topic)
88 MyPresence.track(pid, topic, "u1", %{name: "u1"})
90 assert_receive %Broadcast{topic: ^topic, event: "presence_diff", payload: %{
95 MyPresence.list(topic)
98 assert_receive %Broadcast{topic: ^topic, event: "presence_diff", payload: %{
102 assert MyPresence.list(topic) == %{}
105 test "untrack with pid", %{topic: topic} = config do
106 Phoenix.PubSub.subscribe(config.pubsub, config.topic)
107 MyPresence.track(self(), config.topic, "u1", %{})
108 assert %{"u1" => %{metas: [%{}]}} = MyPresence.list(config.topic)
109 assert MyPresence.untrack(self(), config.topic, "u1") == :ok
110 assert_receive %Broadcast{topic: ^topic, event: "presence_diff", payload: %{
114 assert %{} = MyPresence.list(config.topic)
117 test "track and untrack with %Socket{}", %{topic: topic} = config do
118 Phoenix.PubSub.subscribe(config.pubsub, topic)
119 socket = %Phoenix.Socket{topic: topic, channel_pid: self()}
121 assert %{"u1" => %{metas: [%{}]}} = MyPresence.list(topic)
123 assert_receive %Broadcast{topic: ^topic, event: "presence_diff", payload: %{
127 assert %{} = MyPresence.list(topic)
131 assert MyPresence.untrack(self(), config.topic, "u1") == :ok
134 test "update sends join and leave diff", %{topic: topic} = config do
135 Phoenix.PubSub.subscribe(config.pubsub, topic)
136 MyPresence.track(self(), topic, "u1", %{name: "u1"})
137 assert %{"u1" => %{metas: [%{name: "u1"}]}} = MyPresence.list(topic)
138 assert {:ok, _} = MyPresence.update(self(), topic, "u1", %{name: "updated"})
139 assert_receive %Broadcast{topic: ^topic, event: "presence_diff", payload: %{
143 assert %{} = MyPresence.list(topic)
144 assert %{"u1" => %{metas: [%{name: "updated"}]}} = MyPresence.list(topic)
148 assert MyPresence.update(self(), "topic", "u1", %{}) == {:error, :nopresence}