switch to sqlite, generate new project as 'quip'

This commit is contained in:
2024-09-02 19:47:01 -04:00
parent 3e77cb13b2
commit f5c2b7d67e
47 changed files with 220 additions and 231 deletions

View File

@@ -1,14 +0,0 @@
defmodule PhoenixTestWeb.ErrorHTMLTest do
use PhoenixTestWeb.ConnCase, async: true
# Bring render_to_string/4 for testing custom views
import Phoenix.Template
test "renders 404.html" do
assert render_to_string(PhoenixTestWeb.ErrorHTML, "404", "html", []) == "Not Found"
end
test "renders 500.html" do
assert render_to_string(PhoenixTestWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
end
end

View File

@@ -1,12 +0,0 @@
defmodule PhoenixTestWeb.ErrorJSONTest do
use PhoenixTestWeb.ConnCase, async: true
test "renders 404" do
assert PhoenixTestWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
end
test "renders 500" do
assert PhoenixTestWeb.ErrorJSON.render("500.json", %{}) ==
%{errors: %{detail: "Internal Server Error"}}
end
end

View File

@@ -0,0 +1,14 @@
defmodule QuipWeb.ErrorHTMLTest do
use QuipWeb.ConnCase, async: true
# Bring render_to_string/4 for testing custom views
import Phoenix.Template
test "renders 404.html" do
assert render_to_string(QuipWeb.ErrorHTML, "404", "html", []) == "Not Found"
end
test "renders 500.html" do
assert render_to_string(QuipWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
end
end

View File

@@ -0,0 +1,12 @@
defmodule QuipWeb.ErrorJSONTest do
use QuipWeb.ConnCase, async: true
test "renders 404" do
assert QuipWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
end
test "renders 500" do
assert QuipWeb.ErrorJSON.render("500.json", %{}) ==
%{errors: %{detail: "Internal Server Error"}}
end
end

View File

@@ -1,5 +1,5 @@
defmodule PhoenixTestWeb.PageControllerTest do
use PhoenixTestWeb.ConnCase
defmodule QuipWeb.PageControllerTest do
use QuipWeb.ConnCase
test "GET /", %{conn: conn} do
conn = get(conn, ~p"/")

View File

@@ -1,4 +1,4 @@
defmodule PhoenixTestWeb.ConnCase do
defmodule QuipWeb.ConnCase do
@moduledoc """
This module defines the test case to be used by
tests that require setting up a connection.
@@ -11,7 +11,7 @@ defmodule PhoenixTestWeb.ConnCase do
we enable the SQL sandbox, so changes done to the database
are reverted at the end of every test. If you are using
PostgreSQL, you can even run database tests asynchronously
by setting `use PhoenixTestWeb.ConnCase, async: true`, although
by setting `use QuipWeb.ConnCase, async: true`, although
this option is not recommended for other databases.
"""
@@ -20,19 +20,19 @@ defmodule PhoenixTestWeb.ConnCase do
using do
quote do
# The default endpoint for testing
@endpoint PhoenixTestWeb.Endpoint
@endpoint QuipWeb.Endpoint
use PhoenixTestWeb, :verified_routes
use QuipWeb, :verified_routes
# Import conveniences for testing with connections
import Plug.Conn
import Phoenix.ConnTest
import PhoenixTestWeb.ConnCase
import QuipWeb.ConnCase
end
end
setup tags do
PhoenixTest.DataCase.setup_sandbox(tags)
Quip.DataCase.setup_sandbox(tags)
{:ok, conn: Phoenix.ConnTest.build_conn()}
end
end

View File

@@ -1,4 +1,4 @@
defmodule PhoenixTest.DataCase do
defmodule Quip.DataCase do
@moduledoc """
This module defines the setup for tests requiring
access to the application's data layer.
@@ -10,7 +10,7 @@ defmodule PhoenixTest.DataCase do
we enable the SQL sandbox, so changes done to the database
are reverted at the end of every test. If you are using
PostgreSQL, you can even run database tests asynchronously
by setting `use PhoenixTest.DataCase, async: true`, although
by setting `use Quip.DataCase, async: true`, although
this option is not recommended for other databases.
"""
@@ -18,17 +18,17 @@ defmodule PhoenixTest.DataCase do
using do
quote do
alias PhoenixTest.Repo
alias Quip.Repo
import Ecto
import Ecto.Changeset
import Ecto.Query
import PhoenixTest.DataCase
import Quip.DataCase
end
end
setup tags do
PhoenixTest.DataCase.setup_sandbox(tags)
Quip.DataCase.setup_sandbox(tags)
:ok
end
@@ -36,7 +36,7 @@ defmodule PhoenixTest.DataCase do
Sets up the sandbox based on the test tags.
"""
def setup_sandbox(tags) do
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(PhoenixTest.Repo, shared: not tags[:async])
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Quip.Repo, shared: not tags[:async])
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
end

View File

@@ -1,2 +1,2 @@
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(PhoenixTest.Repo, :manual)
Ecto.Adapters.SQL.Sandbox.mode(Quip.Repo, :manual)