From e19d2ed8f51618a68ae4898a2d2a5b5af7bd676e Mon Sep 17 00:00:00 2001 From: Nick Kezhaya Date: Tue, 15 Oct 2019 16:32:46 -0500 Subject: [PATCH] Call System.cmd during config --- config/config.exs | 12 ++++++++++++ lib/stripe_mock/repo.ex | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config/config.exs b/config/config.exs index 0a8e523..4efdc76 100644 --- a/config/config.exs +++ b/config/config.exs @@ -23,6 +23,18 @@ config :logger, :console, # Use Jason for JSON parsing in Phoenix config :phoenix, :json_library, Jason +{uri, _} = System.cmd("pg_tmp", ["-t"]) +[_, port] = Regex.scan(~r/\:(\d+)\//, uri) |> List.flatten() + +config :stripe_mock, StripeMock.Repo, + adapter: Ecto.Adapters.Postgres, + username: "postgres", + password: "postgres", + database: "test", + hostname: "localhost", + port: port, + pool_size: 10 + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/lib/stripe_mock/repo.ex b/lib/stripe_mock/repo.ex index 322e410..e8aa726 100644 --- a/lib/stripe_mock/repo.ex +++ b/lib/stripe_mock/repo.ex @@ -1,16 +1,4 @@ defmodule StripeMock.Repo do - @moduledoc """ - This is where we store everything. Obviously, don't call any of these - functions yourself. - - State structure is: - - %{ - customer: %{ - "cus_123123" => %Customer{} - } - } - """ use GenServer import Ecto.Changeset alias Ecto.Changeset