Skip to content

Commit 77a91d3

Browse files
committed
Merge branch 'foo' into further-memory-improvements
upgrade tests
2 parents 6e6ed49 + 4ea707b commit 77a91d3

File tree

3 files changed

+40
-36
lines changed

3 files changed

+40
-36
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ missing_rules.rb
1212
.DS_Store
1313
/priv/plts/*.plt
1414
/priv/plts/*.plt.hash
15+
.vscode/

test/absinthe/execution/subscription_test.exs

+2-36
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,6 @@ defmodule Absinthe.Execution.SubscriptionTest do
33

44
import ExUnit.CaptureLog
55

6-
defmodule PubSub do
7-
@behaviour Absinthe.Subscription.Pubsub
8-
9-
def start_link() do
10-
Registry.start_link(keys: :unique, name: __MODULE__)
11-
end
12-
13-
def node_name() do
14-
node()
15-
end
16-
17-
def subscribe(topic) do
18-
Registry.register(__MODULE__, topic, [])
19-
:ok
20-
end
21-
22-
def publish_subscription(topic, data) do
23-
message = %{
24-
topic: topic,
25-
event: "subscription:data",
26-
result: data
27-
}
28-
29-
Registry.dispatch(__MODULE__, topic, fn entries ->
30-
for {pid, _} <- entries, do: send(pid, {:broadcast, message})
31-
end)
32-
end
33-
34-
def publish_mutation(_proxy_topic, _mutation_result, _subscribed_fields) do
35-
# this pubsub is local and doesn't support clusters
36-
:ok
37-
end
38-
end
39-
406
defmodule Schema do
417
use Absinthe.Schema
428

@@ -154,8 +120,8 @@ defmodule Absinthe.Execution.SubscriptionTest do
154120
end
155121

156122
setup_all do
157-
{:ok, _} = PubSub.start_link()
158-
{:ok, _} = Absinthe.Subscription.start_link(PubSub)
123+
{:ok, _} = start_supervised(PubSub)
124+
{:ok, _} = start_supervised({Absinthe.Subscription, [PubSub]})
159125
:ok
160126
end
161127

test/support/pubsub.ex

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
defmodule PubSub do
2+
@behaviour Absinthe.Subscription.Pubsub
3+
4+
def child_spec(opts) do
5+
opts =
6+
opts
7+
|> Keyword.merge(keys: :unique, name: __MODULE__)
8+
9+
Registry.child_spec(opts)
10+
end
11+
12+
def node_name() do
13+
node()
14+
end
15+
16+
def subscribe(topic) do
17+
Registry.register(__MODULE__, topic, [])
18+
:ok
19+
end
20+
21+
def publish_subscription(topic, data) do
22+
message = %{
23+
topic: topic,
24+
event: "subscription:data",
25+
result: data
26+
}
27+
28+
Registry.dispatch(__MODULE__, topic, fn entries ->
29+
for {pid, _} <- entries, do: send(pid, {:broadcast, message})
30+
end)
31+
end
32+
33+
def publish_mutation(_proxy_topic, _mutation_result, _subscribed_fields) do
34+
# this pubsub is local and doesn't support clusters
35+
:ok
36+
end
37+
end

0 commit comments

Comments
 (0)