‘Subscribing to external topics’ is really interesting concept.
https://hexdocs.pm/phoenix/1.3.0/Phoenix.Channel.html#module-subscribing-to-external-topics
But I can’t find the way to test the subscription of channel. How to do that?
‘Subscribing to external topics’ is really interesting concept.
https://hexdocs.pm/phoenix/1.3.0/Phoenix.Channel.html#module-subscribing-to-external-topics
But I can’t find the way to test the subscription of channel. How to do that?
What exactly are you trying to test? That a message was sent? That a message was received? Something else?
That socket is really subscribing a channel.
For example,
def join("test", %{"id" => id}, socket) do
:ok = TestWeb.Endpoint.subscribe("id:#{id}")
{:ok, socket}
end
I want to know I didn’t forget subscribing “id:#{id}” on test.
Hmmm, usually I would assert that a message that is sent to the "id:#{id}"
topic is received by the test process. Perhaps you could create a helper that will assert that the a test-specific message is received.