From 728728a5a4ea63764c6178242be8350515f7e6b0 Mon Sep 17 00:00:00 2001 From: shibao Date: Sat, 22 Jan 2022 20:44:38 -0500 Subject: [PATCH] fix tests --- lib/lokal/accounts.ex | 2 +- lib/lokal/accounts/user.ex | 4 ++++ lib/lokal/accounts/user_notifier.ex | 4 ++++ lib/lokal/accounts/user_token.ex | 4 ++++ lib/lokal/mailer.ex | 4 ++++ lib/lokal/release.ex | 4 ++++ lib/lokal/repo/migrator.ex | 4 ++++ lib/lokal_web/component/topbar.ex | 2 +- lib/lokal_web/controllers/user_auth.ex | 4 ++++ lib/lokal_web/live/live_helpers.ex | 6 +++++- lib/lokal_web/live/modal_component.ex | 4 ++++ lib/lokal_web/live/page_live.ex | 4 ++++ lib/lokal_web/telemetry.ex | 4 ++++ lib/lokal_web/views/layout_view.ex | 2 +- test/support/channel_case.ex | 5 +++-- test/support/conn_case.ex | 5 +++-- test/support/data_case.ex | 5 +++-- 17 files changed, 57 insertions(+), 10 deletions(-) diff --git a/lib/lokal/accounts.ex b/lib/lokal/accounts.ex index b475985..40eb1a2 100644 --- a/lib/lokal/accounts.ex +++ b/lib/lokal/accounts.ex @@ -5,7 +5,7 @@ defmodule Lokal.Accounts do import Ecto.Query, warn: false alias Lokal.Repo - alias Lokal.Accounts.{User, UserToken, UserNotifier} + alias Lokal.Accounts.{User, UserNotifier, UserToken} ## Database getters diff --git a/lib/lokal/accounts/user.ex b/lib/lokal/accounts/user.ex index 4fc41c8..91eb2a4 100644 --- a/lib/lokal/accounts/user.ex +++ b/lib/lokal/accounts/user.ex @@ -1,4 +1,8 @@ defmodule Lokal.Accounts.User do + @moduledoc """ + Schema for a registered user + """ + use Ecto.Schema import Ecto.Changeset diff --git a/lib/lokal/accounts/user_notifier.ex b/lib/lokal/accounts/user_notifier.ex index eefbfb1..10a9c6d 100644 --- a/lib/lokal/accounts/user_notifier.ex +++ b/lib/lokal/accounts/user_notifier.ex @@ -1,4 +1,8 @@ defmodule Lokal.Accounts.UserNotifier do + @moduledoc """ + Contains templates and messages for user messages + """ + # For simplicity, this module simply logs messages to the terminal. # You should replace it by a proper email or notification tool, such as: # diff --git a/lib/lokal/accounts/user_token.ex b/lib/lokal/accounts/user_token.ex index 286ed77..e37c77f 100644 --- a/lib/lokal/accounts/user_token.ex +++ b/lib/lokal/accounts/user_token.ex @@ -1,4 +1,8 @@ defmodule Lokal.Accounts.UserToken do + @moduledoc """ + Schema for a user's session token + """ + use Ecto.Schema import Ecto.Query diff --git a/lib/lokal/mailer.ex b/lib/lokal/mailer.ex index c593a30..51fd1dc 100644 --- a/lib/lokal/mailer.ex +++ b/lib/lokal/mailer.ex @@ -1,3 +1,7 @@ defmodule Lokal.Mailer do + @moduledoc """ + Mailer, currently uses Swoosh + """ + use Swoosh.Mailer, otp_app: :lokal end diff --git a/lib/lokal/release.ex b/lib/lokal/release.ex index ff8779c..eb88117 100644 --- a/lib/lokal/release.ex +++ b/lib/lokal/release.ex @@ -1,4 +1,8 @@ defmodule Lokal.Release do + @moduledoc """ + Contains mix tasks that can used in generated releases + """ + @app :lokal def rollback(repo, version) do diff --git a/lib/lokal/repo/migrator.ex b/lib/lokal/repo/migrator.ex index 2c2fe1a..86eb63d 100644 --- a/lib/lokal/repo/migrator.ex +++ b/lib/lokal/repo/migrator.ex @@ -1,4 +1,8 @@ defmodule Lokal.Repo.Migrator do + @moduledoc """ + Genserver to automatically perform all migration on app start + """ + use GenServer require Logger diff --git a/lib/lokal_web/component/topbar.ex b/lib/lokal_web/component/topbar.ex index 46ccd25..bf10a26 100644 --- a/lib/lokal_web/component/topbar.ex +++ b/lib/lokal_web/component/topbar.ex @@ -5,7 +5,7 @@ defmodule LokalWeb.Component.Topbar do """ use LokalWeb, :component - alias LokalWeb.{PageLive} + alias LokalWeb.PageLive def topbar(assigns) do assigns = diff --git a/lib/lokal_web/controllers/user_auth.ex b/lib/lokal_web/controllers/user_auth.ex index 4d1e8bc..de99448 100644 --- a/lib/lokal_web/controllers/user_auth.ex +++ b/lib/lokal_web/controllers/user_auth.ex @@ -1,4 +1,8 @@ defmodule LokalWeb.UserAuth do + @moduledoc """ + Module for any user authentication functions + """ + import Plug.Conn import Phoenix.Controller diff --git a/lib/lokal_web/live/live_helpers.ex b/lib/lokal_web/live/live_helpers.ex index eb2e9c3..eee3e9b 100644 --- a/lib/lokal_web/live/live_helpers.ex +++ b/lib/lokal_web/live/live_helpers.ex @@ -1,7 +1,11 @@ defmodule LokalWeb.LiveHelpers do + @moduledoc """ + Contains resuable methods for all liveviews + """ + import Phoenix.LiveView.Helpers import Phoenix.LiveView, only: [assign_new: 3] - alias Lokal.{Accounts} + alias Lokal.Accounts @doc """ Renders a component inside the `LokalWeb.ModalComponent` component. diff --git a/lib/lokal_web/live/modal_component.ex b/lib/lokal_web/live/modal_component.ex index 5ab2c60..b55e870 100644 --- a/lib/lokal_web/live/modal_component.ex +++ b/lib/lokal_web/live/modal_component.ex @@ -1,4 +1,8 @@ defmodule LokalWeb.ModalComponent do + @moduledoc """ + Component that provides a floating modal + """ + use LokalWeb, :live_component @impl true diff --git a/lib/lokal_web/live/page_live.ex b/lib/lokal_web/live/page_live.ex index 2ebe702..c3d97a7 100644 --- a/lib/lokal_web/live/page_live.ex +++ b/lib/lokal_web/live/page_live.ex @@ -1,4 +1,8 @@ defmodule LokalWeb.PageLive do + @moduledoc """ + Liveview for the main home page + """ + use LokalWeb, :live_view @impl true diff --git a/lib/lokal_web/telemetry.ex b/lib/lokal_web/telemetry.ex index 6459b6b..c30cb18 100644 --- a/lib/lokal_web/telemetry.ex +++ b/lib/lokal_web/telemetry.ex @@ -1,4 +1,8 @@ defmodule LokalWeb.Telemetry do + @moduledoc """ + Telemetry genserver + """ + use Supervisor import Telemetry.Metrics diff --git a/lib/lokal_web/views/layout_view.ex b/lib/lokal_web/views/layout_view.ex index c62003b..ea3ba06 100644 --- a/lib/lokal_web/views/layout_view.ex +++ b/lib/lokal_web/views/layout_view.ex @@ -1,6 +1,6 @@ defmodule LokalWeb.LayoutView do use LokalWeb, :view - alias LokalWeb.{PageLive} + alias LokalWeb.PageLive # Phoenix LiveDashboard is available only in development by default, # so we instruct Elixir to not warn if the dashboard route is missing. diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex index 36c73f2..92fa608 100644 --- a/test/support/channel_case.ex +++ b/test/support/channel_case.ex @@ -16,6 +16,7 @@ defmodule LokalWeb.ChannelCase do """ use ExUnit.CaseTemplate + alias Ecto.Adapters.SQL.Sandbox using do quote do @@ -29,8 +30,8 @@ defmodule LokalWeb.ChannelCase do end setup tags do - pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Lokal.Repo, shared: not tags[:async]) - on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) + pid = Sandbox.start_owner!(Lokal.Repo, shared: not tags[:async]) + on_exit(fn -> Sandbox.stop_owner(pid) end) :ok end end diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index 3ed880b..5fecabf 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -16,6 +16,7 @@ defmodule LokalWeb.ConnCase do """ use ExUnit.CaseTemplate + alias Ecto.Adapters.SQL.Sandbox using do quote do @@ -32,8 +33,8 @@ defmodule LokalWeb.ConnCase do end setup tags do - pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Lokal.Repo, shared: not tags[:async]) - on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) + pid = Sandbox.start_owner!(Lokal.Repo, shared: not tags[:async]) + on_exit(fn -> Sandbox.stop_owner(pid) end) {:ok, conn: Phoenix.ConnTest.build_conn()} end diff --git a/test/support/data_case.ex b/test/support/data_case.ex index 269a015..6230fc5 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -15,6 +15,7 @@ defmodule Lokal.DataCase do """ use ExUnit.CaseTemplate + alias Ecto.Adapters.SQL.Sandbox using do quote do @@ -28,8 +29,8 @@ defmodule Lokal.DataCase do end setup tags do - pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Lokal.Repo, shared: not tags[:async]) - on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) + pid = Sandbox.start_owner!(Lokal.Repo, shared: not tags[:async]) + on_exit(fn -> Sandbox.stop_owner(pid) end) :ok end