Ownership process error running phoenix test in elixir 1.3.2
use ExUnit.Case, async: true
use Plug.Test
You have code for setup hook in "test/support/channel_case.ex" but you are not using it anywhere in your test or at least it is not clear if you do use it. It would be helpful if you can add this:
IO.puts "#{inspect __MODULE__}: setup is getting called."
somewhere in your setup hook's code. This will make sure that the code actually runs. My suspicion from the comment you made in my previous answer this code is dead.
defmodule ListingMoviesIntegrationTest do
use ExUnit.Case, async: true
use Plug.Test
alias Watchlist.Router
setup do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Watchlist.Repo)
Ecto.Adapters.SQL.Sandbox.mode(Watchlist.Repo, {:shared, self()})
:ok
end
@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
...
I got the same error and in my case on Elixir 1.8.2, Phoenix 1.4.1: after looking at this Elixir forum thread, I changed my test_helpers.exs
to have the line below to have the adapter pool mode from manual to auto.
Ecto.Adapters.SQL.Sandbox.mode(MyApp.Repo, :auto)
You can read more about this about the modes and pool checkout and ownership on the Hex Ecto docs