4
votes

I am working on ex_admin and ran into a problem starting the Phoenix server. I am working on setting up integration tests with Hound. ex_admin has a Phoenix endpoint in the test/support framework. When I set the config for the endpoint server to true I get an error:

    ** (EXIT from #PID<0.70.0>) shutdown: failed to start child: Phoenix.Endpoint.Server
   ** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, TestExAdmin.Endpoint.HTTP}
       ** (EXIT) exited in: :gen_server.call(:ranch_server, {:set_new_listener_opts, TestExAdmin.Endpoint.HTTP, 16384, [env: [dispatch: [{:_, [], [{:_, [], Plug.Adapters.Cowboy.Handler, {TestExAdmin.Endpoint, []}}]}]]]})
           ** (EXIT) no process

You can see the code here: https://github.com/gwincr11/ex_admin

Thanks for any help!

1

1 Answers

5
votes

The error means that Phoenix.Endpoint.Server failed to start a :ranch_listener_sup because :ranch_server was not running. This is because you are not starting cowboy (ranch is a dependency of cowboy and will automatically be started if you start cowboy) in your test env.

To fix this, you can either add the following to the top of test/test_helper.exs:

Application.ensure_all_started(:cowboy)

Or add it as a dependency in :test env in mix.exs:

defp applications(:test) do
  [:plug, :cowboy | applications(:prod)]
end

After making either one of these changes, I no longer get that error in your codebase (but I get 7 test failures which you probably added and not had the chance to fix).