I am working on a phoenix tutorial, but I have this error:
** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.265.0>.
I do not use Task.start , so nothing should be started asynchronously, and I thought that in order to prevent this error, in test/support/channel_case.ex :
it would be sufficient to use
unless tag
unless setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(Watchlist.Repo) unless tags[:async] do Ecto.Adapters.SQL.Sandbox.mode(Watchlist.Repo, {:shared, self()}) end :ok end
So, I am curious how I resolve this error.
This is how I run it:
mix test test/integration/listing_movies_test.exs
I am using elixir 1.3.2
UPDATE
defmodule ListingMoviesIntegrationTest do use ExUnit.Case, async: true use Plug.Test alias Watchlist.Router @opts Router.init([]) test 'listing movies' do movie = %Movie{name: "Back to the future", rating: 5} |> Repo.insert! <== error happens here conn = conn(:get, "/movies") response = Router.call(conn, @opts) assert response.status == 200 assert response.resp_body == movie end
Full stack trace:
(db_connection) lib/db_connection.ex:718: DBConnection.checkout/2 (db_connection) lib/db_connection.ex:619: DBConnection.run/3 (db_connection) lib/db_connection.ex:463: DBConnection.prepare_execute/4 (ecto) lib/ecto/adapters/postgres/connection.ex:91: Ecto.Adapters.Postgres.Connection.execute/4 (ecto) lib/ecto/adapters/sql.ex:235: Ecto.Adapters.SQL.sql_call/6 (ecto) lib/ecto/adapters/sql.ex:454: Ecto.Adapters.SQL.struct/6 (ecto) lib/ecto/repo/schema.ex:397: Ecto.Repo.Schema.apply/4 (ecto) lib/ecto/repo/schema.ex:193: anonymous fn/11 in Ecto.Repo.Schema.do_insert/4 (ecto) lib/ecto/repo/schema.ex:124: Ecto.Repo.Schema.insert!/4 test/integration/listing_movies_test.exs:13: (test)
and in test_helper, which is actually called when I insert the debug statement:
ExUnit.start Ecto.Adapters.SQL.Sandbox.mode(Watchlist.Repo, :manual) Ecto.Adapters.SQL.Sandbox.mode(Watchlist.Repo, {:shared, self()})