Skip to content

Commit

Permalink
Define child_spec for Postgrex.Notifications, closes #548
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jul 27, 2021
1 parent e6052cb commit 194488f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/postgrex/notifications.ex
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ defmodule Postgrex.Notifications do

@type server :: GenServer.server()

@doc false
def child_spec(opts) do
%{
id: __MODULE__,
start: {__MODULE__, :start_link, [opts]}
}
end

@doc """
Start the notification connection process and connect to postgres.
Expand Down
4 changes: 4 additions & 0 deletions test/notification_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ defmodule NotificationTest do
{:ok, [pid: pid, pid_ps: pid_ps]}
end

test "defines child spec" do
start_supervised!({PN, @opts})
end

test "fails on sync connection by default" do
Process.flag(:trap_exit, true)
assert {:error, _} = PN.start_link(database: "nobody_knows_it")
Expand Down

0 comments on commit 194488f

Please sign in to comment.