Hi,
i followed the examples and generated the Catalog live ressource as described on page 67, added the /product routes in the corresponding /-Scope with the :require_authenticated_user plug. Now mix test fails as expected on page 69. Now, when i add the :register_and_log_in_user plug to the Index and Show test blocks, the tests should not fail anymore.
In my case, i get another 6 failures on running mix test:
1) test Show displays product (PentoWeb.ProductLiveTest)
test/pento_web/live/product_live_test.exs:88
** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Show.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Show is not available)
code: {:ok, _show_live, html} = live(conn, ~p"/products/#{product}")
stacktrace:
PentoWeb.PentoWeb.ProductLive.Show.__live__()
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
(phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
(phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
(phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
test/pento_web/live/product_live_test.exs:89: (test)
2) test Index lists all products (PentoWeb.ProductLiveTest)
test/pento_web/live/product_live_test.exs:24
** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Index.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Index is not available)
code: {:ok, _index_live, html} = live(conn, ~p"/products")
stacktrace:
PentoWeb.PentoWeb.ProductLive.Index.__live__()
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
(phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
(phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
(phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
test/pento_web/live/product_live_test.exs:25: (test)
3) test Show updates product within modal (PentoWeb.ProductLiveTest)
test/pento_web/live/product_live_test.exs:95
** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Show.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Show is not available)
code: {:ok, show_live, _html} = live(conn, ~p"/products/#{product}")
stacktrace:
PentoWeb.PentoWeb.ProductLive.Show.__live__()
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
(phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
(phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
(phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
test/pento_web/live/product_live_test.exs:96: (test)
4) test Index saves new product (PentoWeb.ProductLiveTest)
test/pento_web/live/product_live_test.exs:31
** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Index.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Index is not available)
code: {:ok, index_live, _html} = live(conn, ~p"/products")
stacktrace:
PentoWeb.PentoWeb.ProductLive.Index.__live__()
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
(phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
(phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
(phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
test/pento_web/live/product_live_test.exs:32: (test)
5) test Index deletes product in listing (PentoWeb.ProductLiveTest)
test/pento_web/live/product_live_test.exs:77
** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Index.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Index is not available)
code: {:ok, index_live, _html} = live(conn, ~p"/products")
stacktrace:
PentoWeb.PentoWeb.ProductLive.Index.__live__()
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
(phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
(phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
(phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
test/pento_web/live/product_live_test.exs:78: (test)
6) test Index updates product in listing (PentoWeb.ProductLiveTest)
test/pento_web/live/product_live_test.exs:54
** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Index.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Index is not available)
code: {:ok, index_live, _html} = live(conn, ~p"/products")
stacktrace:
PentoWeb.PentoWeb.ProductLive.Index.__live__()
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
(phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
(phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
(phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
(pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
(phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
test/pento_web/live/product_live_test.exs:55: (test)
...........................................................
Finished in 0.5 seconds (0.3s async, 0.2s sync)
142 tests, 6 failures
My guess is the PentoWeb.PentoWeb.ProductLive.Index part has one “PentoWeb” too much. But i cannot see where this should be defined.
Any ideas how to trace this down and fix it?