From 444bc2dc85ea307e8cf9e3fc5a3de791c4c5eb18 Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Tue, 29 Aug 2023 14:38:14 +0200 Subject: [PATCH] Add :ssl to :extra_applications (#658) --- lib/postgrex.ex | 18 ------------------ mix.exs | 4 ++-- test/postgrex_test.exs | 12 ------------ 3 files changed, 2 insertions(+), 32 deletions(-) diff --git a/lib/postgrex.ex b/lib/postgrex.ex index cf97cdee..b82f4e97 100644 --- a/lib/postgrex.ex +++ b/lib/postgrex.ex @@ -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 @@ -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 @@ -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 diff --git a/mix.exs b/mix.exs index aff8cbb7..d65fd12e 100644 --- a/mix.exs +++ b/mix.exs @@ -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] ] diff --git a/test/postgrex_test.exs b/test/postgrex_test.exs index 56ff13ff..752e8d18 100644 --- a/test/postgrex_test.exs +++ b/test/postgrex_test.exs @@ -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"]