1

我有一个使用 Ecto 和 Postgrex 的库(Postgrex 仅用于测试)。

从 Ecto 1 升级到 Ecto 2 后,测试套件开始出现此错误:

$ mix test
Compiling 4 files (.ex)
Generated ectoo app
** (EXIT from #PID<0.46.0>) shutdown: failed to start child: DBConnection.Ownership.Manager
    ** (EXIT) exited in: GenServer.call(DBConnection.Ownership.PoolSupervisor, {:start_child, [#PID<0.175.0>, Postgrex.Protocol, [pool: DBConnection.Poolboy, types: true, hostname: "localhost", types: true, otp_app: :ectoo, repo: Ectoo.Repo, adapter: Ecto.Adapters.Postgres, database: "ectoo_test", username: "henrik", pool_timeout: 5000, timeout: 15000, adapter: Ecto.Adapters.Postgres, database: "ectoo_test", username: "henrik", extensions: [{Ecto.Adapters.Postgres.DateTime, []}, {Postgrex.Extensions.JSON, [library: nil]}], port: 5432]]}, :infinity)
        ** (EXIT) no process

有任何想法吗?

4

1 回答 1

4

我通过确保postgrex应用程序在测试运行时正在运行来解决这个问题。

在 mix.exs 中:

def application do
  [applications: applications(Mix.env)]
end

defp applications(:test), do: [:logger, :postgrex]
defp applications(_), do: [:logger]
于 2016-06-24T09:30:48.777 回答