title: Ownership process error running phoenix test in elixir 1.3.2
body: <p>I am working through a phoenix tutorial but I have this error:</p>
  
  <pre><code> ** (DBConnection.OwnershipError) cannot find ownership process for #PID&lt;0.265.0&gt;.
  </code></pre>
  
  <p>I am not using <code>Task.start</code> so nothing should be running asynchronously, and I thought that having the mode in the <code>unless</code> tag would be enough to prevent this error, in <code>test/support/channel_case.ex</code>:</p>
  
  <pre><code>  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
  </code></pre>
  
  <p>So, I am curious how I resolve this error.</p>
  
  <p>This is how I run it:</p>
  
  <p><code>mix test test/integration/listing_movies_test.exs</code></p>
  
  <p>I am using elixir 1.3.2</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>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}
              |&gt; Repo.insert!   &lt;== error happens here
  
      conn = conn(:get, "/movies")
      response = Router.call(conn, @opts)
  
      assert response.status == 200
      assert response.resp_body == movie
    end
  </code></pre>
  
  <p>Full stack trace:</p>
  
  <pre><code>(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)
  </code></pre>
  
  <p>and in test_helper which is actually being called as I put in a debug statement:</p>
  
  <pre><code>ExUnit.start
  
  Ecto.Adapters.SQL.Sandbox.mode(Watchlist.Repo, :manual)
  Ecto.Adapters.SQL.Sandbox.mode(Watchlist.Repo, {:shared, self()})
  </code></pre>