Programming Phoenix 1.4 -- Channel tests all fail

I have created a repo for my issue: GitHub - shawarmaz/rumbl_umbrella

At the last section of the last chapter of the Programming Phoenix 1.4 book which relate to testing channels, running mix test raises the errors below (1)

The errors are inconsistent and sometimes I get one that says:

warning: InfoSys.Test.HTTPClient.request/1 is undefined (module InfoSys.Test.HTTPClient is not available or is yet to be defined)
  lib/info_sys/wolfram.ex:4 InfoSys.Wolfram.fetch_data/1

For which I found this thread

When I run just the faulty tests using mix test apps/rumbl_web/test/rumbl_web/channels/video_channel_test.exs I get an even more cryptic set of errors (2):

I have absolutely no idea how to approach debugging this. Any help at all would be greatly appreciated.

(1)

..................21:31:40.203 [error] Task #PID<0.651.0> started from RumblWeb.Presence_shard0 terminating
** (stop) exited in: DBConnection.Holder.checkout(#PID<0.646.0>, [log: #Function<15.17938311/1 in Ecto.Adapters.SQL.with_log/3>, source: "users", timeout: 15000, pool_size: 10, pool: DBConnection.Ownership])
    ** (EXIT) shutdown: "owner #PID<0.645.0> exited"
    (db_connection 2.3.1) lib/db_connection/holder.ex:86: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection/holder.ex:67: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection.ex:1046: DBConnection.checkout/3
    (db_connection 2.3.1) lib/db_connection.ex:1357: DBConnection.run/6
    (db_connection 2.3.1) lib/db_connection.ex:613: DBConnection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/postgres/connection.ex:80: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:702: Ecto.Adapters.SQL.execute!/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:684: Ecto.Adapters.SQL.execute/5
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (rumbl_web 0.1.0) lib/rumbl_web/channels/presence.ex:17: RumblWeb.Presence.fetch/2
    (phoenix 1.5.8) lib/phoenix/presence.ex:365: anonymous fn/4 in Phoenix.Presence.Tracker.handle_diff/2
    (stdlib 3.14) maps.erl:233: :maps.fold_1/3
    (phoenix 1.5.8) lib/phoenix/presence.ex:363: anonymous fn/3 in Phoenix.Presence.Tracker.handle_diff/2
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: #Function<0.132388576/0 in Phoenix.Presence.Tracker.handle_diff/2>
    Args: []
.21:31:40.221 [error] Task #PID<0.655.0> started from RumblWeb.Presence_shard0 terminating
** (stop) exited in: DBConnection.Holder.checkout(#PID<0.653.0>, [log: #Function<15.17938311/1 in Ecto.Adapters.SQL.with_log/3>, source: "users", timeout: 15000, pool_size: 10, pool: DBConnection.Ownership])
    ** (EXIT) shutdown: "owner #PID<0.652.0> exited"
    (db_connection 2.3.1) lib/db_connection/holder.ex:86: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection/holder.ex:67: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection.ex:1046: DBConnection.checkout/3
    (db_connection 2.3.1) lib/db_connection.ex:1357: DBConnection.run/6
    (db_connection 2.3.1) lib/db_connection.ex:613: DBConnection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/postgres/connection.ex:80: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:702: Ecto.Adapters.SQL.execute!/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:684: Ecto.Adapters.SQL.execute/5
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (rumbl_web 0.1.0) lib/rumbl_web/channels/presence.ex:17: RumblWeb.Presence.fetch/2
    (phoenix 1.5.8) lib/phoenix/presence.ex:365: anonymous fn/4 in Phoenix.Presence.Tracker.handle_diff/2
    (stdlib 3.14) maps.erl:233: :maps.fold_1/3
    (phoenix 1.5.8) lib/phoenix/presence.ex:363: anonymous fn/3 in Phoenix.Presence.Tracker.handle_diff/2
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: #Function<0.132388576/0 in Phoenix.Presence.Tracker.handle_diff/2>
    Args: []
21:31:40.224 [error] Task #PID<0.656.0> started from RumblWeb.Presence_shard0 terminating
** (stop) exited in: DBConnection.Holder.checkout(#PID<0.653.0>, [log: #Function<15.17938311/1 in Ecto.Adapters.SQL.with_log/3>, source: "users", timeout: 15000, pool_size: 10, pool: DBConnection.Ownership])
    ** (EXIT) shutdown: "owner #PID<0.652.0> exited"
    (db_connection 2.3.1) lib/db_connection/holder.ex:86: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection/holder.ex:67: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection.ex:1046: DBConnection.checkout/3
    (db_connection 2.3.1) lib/db_connection.ex:1357: DBConnection.run/6
    (db_connection 2.3.1) lib/db_connection.ex:613: DBConnection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/postgres/connection.ex:80: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:702: Ecto.Adapters.SQL.execute!/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:684: Ecto.Adapters.SQL.execute/5
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (rumbl_web 0.1.0) lib/rumbl_web/channels/presence.ex:17: RumblWeb.Presence.fetch/2
    (phoenix 1.5.8) lib/phoenix/presence.ex:365: anonymous fn/4 in Phoenix.Presence.Tracker.handle_diff/2
    (stdlib 3.14) maps.erl:233: :maps.fold_1/3
    (phoenix 1.5.8) lib/phoenix/presence.ex:363: anonymous fn/3 in Phoenix.Presence.Tracker.handle_diff/2
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: #Function<0.132388576/0 in Phoenix.Presence.Tracker.handle_diff/2>
    Args: []
..

Finished in 0.6 seconds
21 tests, 0 failures

Randomized with seed 876999
21:31:40.340 [error] Task #PID<0.663.0> started from RumblWeb.Presence_shard0 terminating
** (stop) exited in: DBConnection.Holder.checkout(#PID<0.658.0>, [log: #Function<15.17938311/1 in Ecto.Adapters.SQL.with_log/3>, source: "users", timeout: 15000, pool_size: 10, pool: DBConnection.Ownership])
    ** (EXIT) shutdown: "owner #PID<0.657.0> exited"
    (db_connection 2.3.1) lib/db_connection/holder.ex:86: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection/holder.ex:67: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection.ex:1046: DBConnection.checkout/3
    (db_connection 2.3.1) lib/db_connection.ex:1357: DBConnection.run/6
    (db_connection 2.3.1) lib/db_connection.ex:613: DBConnection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/postgres/connection.ex:80: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:702: Ecto.Adapters.SQL.execute!/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:684: Ecto.Adapters.SQL.execute/5
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (rumbl_web 0.1.0) lib/rumbl_web/channels/presence.ex:17: RumblWeb.Presence.fetch/2
    (phoenix 1.5.8) lib/phoenix/presence.ex:365: anonymous fn/4 in Phoenix.Presence.Tracker.handle_diff/2
    (stdlib 3.14) maps.erl:233: :maps.fold_1/3
    (phoenix 1.5.8) lib/phoenix/presence.ex:363: anonymous fn/3 in Phoenix.Presence.Tracker.handle_diff/2
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: #Function<0.132388576/0 in Phoenix.Presence.Tracker.handle_diff/2>
    Args: []

(2)

==> rumbl_web
..21:53:12.668 [error] Task #PID<0.449.0> started from RumblWeb.Presence_shard0 terminating
** (stop) exited in: DBConnection.Holder.checkout(#PID<0.445.0>, [log: #Function<15.17938311/1 in Ecto.Adapters.SQL.with_log/3>, source: "users", timeout: 15000, pool_size: 10, pool: DBConnection.Ownership])
    ** (EXIT) shutdown: "owner #PID<0.444.0> exited"
    (db_connection 2.3.1) lib/db_connection/holder.ex:86: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection/holder.ex:67: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection.ex:1046: DBConnection.checkout/3
    (db_connection 2.3.1) lib/db_connection.ex:1357: DBConnection.run/6
    (db_connection 2.3.1) lib/db_connection.ex:613: DBConnection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/postgres/connection.ex:80: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:702: Ecto.Adapters.SQL.execute!/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:684: Ecto.Adapters.SQL.execute/5
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (rumbl_web 0.1.0) lib/rumbl_web/channels/presence.ex:17: RumblWeb.Presence.fetch/2
    (phoenix 1.5.8) lib/phoenix/presence.ex:365: anonymous fn/4 in Phoenix.Presence.Tracker.handle_diff/2
    (stdlib 3.14) maps.erl:233: :maps.fold_1/3
    (phoenix 1.5.8) lib/phoenix/presence.ex:363: anonymous fn/3 in Phoenix.Presence.Tracker.handle_diff/2
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: #Function<0.132388576/0 in Phoenix.Presence.Tracker.handle_diff/2>
    Args: []
21:53:12.668 [error] Task #PID<0.448.0> started from RumblWeb.Presence_shard0 terminating
** (stop) exited in: DBConnection.Holder.checkout(#PID<0.445.0>, [log: #Function<15.17938311/1 in Ecto.Adapters.SQL.with_log/3>, source: "users", timeout: 15000, pool_size: 10, pool: DBConnection.Ownership])
    ** (EXIT) shutdown: "owner #PID<0.444.0> exited"
    (db_connection 2.3.1) lib/db_connection/holder.ex:86: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection/holder.ex:67: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection.ex:1046: DBConnection.checkout/3
    (db_connection 2.3.1) lib/db_connection.ex:1357: DBConnection.run/6
    (db_connection 2.3.1) lib/db_connection.ex:613: DBConnection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/postgres/connection.ex:80: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:702: Ecto.Adapters.SQL.execute!/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:684: Ecto.Adapters.SQL.execute/5
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (rumbl_web 0.1.0) lib/rumbl_web/channels/presence.ex:17: RumblWeb.Presence.fetch/2
    (phoenix 1.5.8) lib/phoenix/presence.ex:365: anonymous fn/4 in Phoenix.Presence.Tracker.handle_diff/2
    (stdlib 3.14) maps.erl:233: :maps.fold_1/3
    (phoenix 1.5.8) lib/phoenix/presence.ex:363: anonymous fn/3 in Phoenix.Presence.Tracker.handle_diff/2
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: #Function<0.132388576/0 in Phoenix.Presence.Tracker.handle_diff/2>
    Args: []
21:53:12.666 [error] Task #PID<0.443.0> started from RumblWeb.Presence_shard0 terminating
** (stop) exited in: DBConnection.Holder.checkout(#PID<0.439.0>, [log: #Function<15.17938311/1 in Ecto.Adapters.SQL.with_log/3>, source: "users", timeout: 15000, pool_size: 10, pool: DBConnection.Ownership])
    ** (EXIT) shutdown: "owner #PID<0.438.0> exited"
    (db_connection 2.3.1) lib/db_connection/holder.ex:86: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection/holder.ex:67: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection.ex:1046: DBConnection.checkout/3
    (db_connection 2.3.1) lib/db_connection.ex:1357: DBConnection.run/6
    (db_connection 2.3.1) lib/db_connection.ex:613: DBConnection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/postgres/connection.ex:80: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:702: Ecto.Adapters.SQL.execute!/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:684: Ecto.Adapters.SQL.execute/5
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (rumbl_web 0.1.0) lib/rumbl_web/channels/presence.ex:17: RumblWeb.Presence.fetch/2
    (phoenix 1.5.8) lib/phoenix/presence.ex:365: anonymous fn/4 in Phoenix.Presence.Tracker.handle_diff/2
    (stdlib 3.14) maps.erl:233: :maps.fold_1/3
    (phoenix 1.5.8) lib/phoenix/presence.ex:363: anonymous fn/3 in Phoenix.Presence.Tracker.handle_diff/2
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: #Function<0.132388576/0 in Phoenix.Presence.Tracker.handle_diff/2>
    Args: []
21:53:12.663 [error] Task #PID<0.446.0> started from #PID<0.442.0> terminating
** (UndefinedFunctionError) function InfoSys.Test.HTTPClient.request/1 is undefined (module InfoSys.Test.HTTPClient is not available)
    InfoSys.Test.HTTPClient.request('http://api.wolframalpha.com/v2/query?appid=1234&input=the+body&format=plaintext')
    (info_sys 0.1.0) lib/info_sys/wolfram.ex:32: InfoSys.Wolfram.fetch_xml/1
    (info_sys 0.1.0) lib/info_sys/wolfram.ex:18: InfoSys.Wolfram.compute/2
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir 1.11.3) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: &InfoSys.Wolfram.compute/2
    Args: ["the body", [limit: 1, timeout: 10000]]
21:53:12.699 [error] Task #PID<0.455.0> started from #PID<0.454.0> terminating
** (UndefinedFunctionError) function InfoSys.Test.HTTPClient.request/1 is undefined (module InfoSys.Test.HTTPClient is not available)
    InfoSys.Test.HTTPClient.request('http://api.wolframalpha.com/v2/query?appid=1234&input=1+%2B+1&format=plaintext')
    (info_sys 0.1.0) lib/info_sys/wolfram.ex:32: InfoSys.Wolfram.fetch_xml/1
    (info_sys 0.1.0) lib/info_sys/wolfram.ex:18: InfoSys.Wolfram.compute/2
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir 1.11.3) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: &InfoSys.Wolfram.compute/2
    Args: ["1 + 1", [limit: 1, timeout: 10000]]
21:53:12.802 [error] Task #PID<0.456.0> started from RumblWeb.Presence_shard0 terminating
** (stop) exited in: DBConnection.Holder.checkout(#PID<0.451.0>, [log: #Function<15.17938311/1 in Ecto.Adapters.SQL.with_log/3>, source: "users", timeout: 15000, pool_size: 10, pool: DBConnection.Ownership])
    ** (EXIT) shutdown: "owner #PID<0.450.0> exited"
    (db_connection 2.3.1) lib/db_connection/holder.ex:86: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection/holder.ex:67: DBConnection.Holder.checkout/2
    (db_connection 2.3.1) lib/db_connection.ex:1046: DBConnection.checkout/3
    (db_connection 2.3.1) lib/db_connection.ex:1357: DBConnection.run/6
    (db_connection 2.3.1) lib/db_connection.ex:613: DBConnection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/postgres/connection.ex:80: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:702: Ecto.Adapters.SQL.execute!/4
    (ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:684: Ecto.Adapters.SQL.execute/5
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
    (ecto 3.5.8) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (rumbl_web 0.1.0) lib/rumbl_web/channels/presence.ex:17: RumblWeb.Presence.fetch/2
    (phoenix 1.5.8) lib/phoenix/presence.ex:365: anonymous fn/4 in Phoenix.Presence.Tracker.handle_diff/2
    (stdlib 3.14) maps.erl:233: :maps.fold_1/3
    (phoenix 1.5.8) lib/phoenix/presence.ex:363: anonymous fn/3 in Phoenix.Presence.Tracker.handle_diff/2
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: #Function<0.132388576/0 in Phoenix.Presence.Tracker.handle_diff/2>
    Args: []


  1) test new annotations trigger InfoSys (RumblWeb.Channels.VideoChannelTest)
     apps/rumbl_web/test/rumbl_web/channels/video_channel_test.exs:33
     Assertion failed, no matching message after 100ms
     Showing 4 of 4 messages in the mailbox
     code: assert_receive %Phoenix.Socket.Broadcast{event: "new_annotation", payload: %{body: "2", at: 123}}
     mailbox:
       pattern: %Phoenix.Socket.Broadcast{
                  event: "new_annotation",
                  payload: %{at: 123, body: "2"}
                }
       value:   %Phoenix.Socket.Message{
                  event: "presence_state",
                  payload: %{},
                  join_ref: 1253,
                  ref: nil,
                  topic: "videos:568"
                }

       pattern: %Phoenix.Socket.Broadcast{
                  event: "new_annotation",
                  payload: %{at: 123, body: "2"}
                }
       value:   %Phoenix.Socket.Broadcast{
                  event: "presence_diff",
                  payload: %{
                    joins: %{"973" => %{metas: [%{device: "browser", phx_ref: "Fm9y9iEWCVienQEC"}], user: %{username: "user1125"}}},
                    leaves: %{}
                  },
                  topic: "videos:568"
                }

       pattern: %Phoenix.Socket.Broadcast{
                  event: "new_annotation",
                  payload: %{at: 123, body: "2"}
                }
       value:   %Phoenix.Socket.Message{
                  event: "presence_diff",
                  payload: %{
                    joins: %{"973" => %{metas: [%{device: "browser", phx_ref: "Fm9y9iEWCVienQEC"}], user: %{username: "user1125"}}},
                    leaves: %{}
                  },
                  join_ref: nil,
                  ref: nil,
                  topic: "videos:568"
                }

       pattern: %Phoenix.Socket.Broadcast{
                  event: "new_annotation",
                  payload: %{at: 123, body: "2"}
                }
       value:   %Phoenix.Socket.Message{
                  event: "new_annotation",
                  payload: %{
                    at: 123,
                    body: "1 + 1",
                    id: 134,
                    user: %{id: 973, username: "user1125"}
                  },
                  join_ref: nil,
                  ref: nil,
                  topic: "videos:568"
                }
     stacktrace:
       test/rumbl_web/channels/video_channel_test.exs:43: (test)



Finished in 0.3 seconds
3 tests, 1 failure

Randomized with seed 409577

It means the database is not connected. Do you have postgres setup correctly, do you have a test database that have the proper migration?

Please read this doc about ecto testing carefully. if in doubt, psql the database.

Also, before running any automatic tests, try to bring the app up in REPL first: iex -S mix and poke around in there to make sure nothing is grossly wrong.

All the other tests that depend on the database work though…Also I just went through the whole book including multiple chapters on testing. Everything was fine until these tests

Looks like it’s a bug.

I just gave up. After a few hours of hair pulling.

NobbZ answered the first part of your question in the first reply to that thread; InfoSys.Test.HTTPClient is referenced at compile-time, so it needs to be in a directory the compiler looks at and it needs to have a .ex extension.


Messages like this are usually an indication that something is trying to use the database connection opened by the test process when the test process has terminated. In this case, it looks like RumblWeb.Presence is still handling an update.

Yes, just couldn’t wrap my head around the fact that this would be in the official book

See issue i linked to above

Same issue

Can’t express how frustrating it is for the book to literally end on such a cryptic-for-beginners bug.

Does this mean we just can’t test channels?

It does not mean this.

In pulling down your code, the issue is relatively straight forward: your test cases are ending before the spawned processes have returned. You’re doing Task.start(fn -> compute_additional_info(annotation, socket) end) which spawns a process but nothing is awaiting on it. When your test case ends, the database connection the task was in the middle of using terminates, and you get the error.

The issue isn’t actually with channels at all, you’d have exactly the same issue if you did the task spawning in a controller.

I agree that it is confusing to see the error messages displayed from these test cases. It’s possible that in the time since phoenix 1.4 something about how channel tests are performed has changed, I’m not sure.

Likewise I think I was a bit hasty with:

I thought the bug was mostly Presence related? see this GitHub issue where Jose and Chris chime in

I got your code running locally and commented out the Task.start line and it didn’t help at all! Let me see what I can do to make the error lines go away.

OK so I created a PR Fix Errors by benwilson512 · Pull Request #1 · shawarmaz/rumbl_umbrella · GitHub which updates the code to use the latest generated within a new Phoenix project. This fixes most of the errors I’m seeing, but I think there are still some happening, will keep investigating.

4 Likes

Fantastic but yeah these are basically the fixes described in issue linked above.

Also once again based on that thread it appears that we should be using the new Presence.fetchers_pids() instead of Task.Supervisor.children(RumblWeb.Presence.TaskSupervisor). However still getting the same errors.