Skip to content

Commit

Permalink
Add :ssl to :extra_applications (#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Aug 29, 2023
1 parent 07bcd21 commit 444bc2d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 32 deletions.
18 changes: 0 additions & 18 deletions lib/postgrex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ defmodule Postgrex do
"""
@spec start_link([start_option]) :: {:ok, pid} | {:error, Postgrex.Error.t() | term}
def start_link(opts) do
ensure_deps_started!(opts)
opts = Postgrex.Utils.default_opts(opts)
DBConnection.start_link(Postgrex.Protocol, opts)
end
Expand Down Expand Up @@ -630,7 +629,6 @@ defmodule Postgrex do
"""
@spec child_spec([start_option]) :: :supervisor.child_spec()
def child_spec(opts) do
ensure_deps_started!(opts)
opts = Postgrex.Utils.default_opts(opts)
DBConnection.child_spec(Postgrex.Protocol, opts)
end
Expand Down Expand Up @@ -682,20 +680,4 @@ defmodule Postgrex do
options = Keyword.put_new(options, :max_rows, @max_rows)
%Postgrex.Stream{conn: conn, query: query, params: params, options: options}
end

## Helpers

defp ensure_deps_started!(opts) do
if Keyword.get(opts, :ssl, false) and
not List.keymember?(:application.which_applications(), :ssl, 0) do
raise """
SSL connection can not be established because `:ssl` application is not started,
you can add it to `extra_applications` in your `mix.exs`:
def application do
[extra_applications: [:ssl]]
end
"""
end
end
end
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ defmodule Postgrex.Mixfile do
description: "PostgreSQL driver for Elixir",
docs: docs(),
package: package(),
xref: [exclude: [Jason, :ssl]]
xref: [exclude: [Jason]]
]
end

# Configuration for the OTP application
def application do
[
extra_applications: [:logger, :crypto],
extra_applications: [:logger, :crypto, :ssl],
mod: {Postgrex.App, []},
env: [type_server_reap_after: 3 * 60_000, json_library: Jason]
]
Expand Down
12 changes: 0 additions & 12 deletions test/postgrex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ defmodule PostgrexTest do
use ExUnit.Case, async: false
import ExUnit.CaptureLog

test "start_link/2 raises when :ssl app is required but not started" do
on_exit(fn ->
Application.start(:ssl)
end)

Application.stop(:ssl)

assert_raise RuntimeError, ~r"SSL connection can not be established", fn ->
Postgrex.start_link(ssl: true, database: "postgrex_test")
end
end

test "start_link/2 sets search path" do
# valid argument
search_path = ["public", "extension"]
Expand Down

0 comments on commit 444bc2d

Please sign in to comment.