this is a really good first commit

This commit is contained in:
2023-01-18 16:13:51 +01:00
parent 6bc40e339a
commit be71f04838
117 changed files with 2972 additions and 3100 deletions

View File

@ -152,9 +152,9 @@ defmodule SomethingErlang.AccountsTest do
test "validates email uniqueness", %{user: user} do
%{email: email} = user_fixture()
password = valid_user_password()
{:error, changeset} =
Accounts.apply_user_email(user, valid_user_password(), %{email: email})
{:error, changeset} = Accounts.apply_user_email(user, password, %{email: email})
assert "has already been taken" in errors_on(changeset).email
end
@ -174,7 +174,7 @@ defmodule SomethingErlang.AccountsTest do
end
end
describe "deliver_update_email_instructions/3" do
describe "deliver_user_update_email_instructions/3" do
setup do
%{user: user_fixture()}
end
@ -182,7 +182,7 @@ defmodule SomethingErlang.AccountsTest do
test "sends token through notification", %{user: user} do
token =
extract_user_token(fn url ->
Accounts.deliver_update_email_instructions(user, "current@example.com", url)
Accounts.deliver_user_update_email_instructions(user, "current@example.com", url)
end)
{:ok, token} = Base.url_decode64(token, padding: false)
@ -200,7 +200,7 @@ defmodule SomethingErlang.AccountsTest do
token =
extract_user_token(fn url ->
Accounts.deliver_update_email_instructions(%{user | email: email}, user.email, url)
Accounts.deliver_user_update_email_instructions(%{user | email: email}, user.email, url)
end)
%{user: user, token: token, email: email}
@ -353,11 +353,11 @@ defmodule SomethingErlang.AccountsTest do
end
end
describe "delete_session_token/1" do
describe "delete_user_session_token/1" do
test "deletes the token" do
user = user_fixture()
token = Accounts.generate_user_session_token(user)
assert Accounts.delete_session_token(token) == :ok
assert Accounts.delete_user_session_token(token) == :ok
refute Accounts.get_user_by_session_token(token)
end
end
@ -500,7 +500,7 @@ defmodule SomethingErlang.AccountsTest do
end
end
describe "inspect/2" do
describe "inspect/2 for the User module" do
test "does not include password" do
refute inspect(%User{password: "123456"}) =~ "password: \"123456\""
end

View File

@ -1,61 +0,0 @@
defmodule SomethingErlang.ForumsTest do
use SomethingErlang.DataCase
alias SomethingErlang.Forums
describe "threads" do
alias SomethingErlang.Forums.Thread
import SomethingErlang.ForumsFixtures
@invalid_attrs %{thread_id: nil, title: nil}
test "list_threads/0 returns all threads" do
thread = thread_fixture()
assert Forums.list_threads() == [thread]
end
test "get_thread!/1 returns the thread with given id" do
thread = thread_fixture()
assert Forums.get_thread!(thread.id) == thread
end
test "create_thread/1 with valid data creates a thread" do
valid_attrs = %{thread_id: 42, title: "some title"}
assert {:ok, %Thread{} = thread} = Forums.create_thread(valid_attrs)
assert thread.thread_id == 42
assert thread.title == "some title"
end
test "create_thread/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Forums.create_thread(@invalid_attrs)
end
test "update_thread/2 with valid data updates the thread" do
thread = thread_fixture()
update_attrs = %{thread_id: 43, title: "some updated title"}
assert {:ok, %Thread{} = thread} = Forums.update_thread(thread, update_attrs)
assert thread.thread_id == 43
assert thread.title == "some updated title"
end
test "update_thread/2 with invalid data returns error changeset" do
thread = thread_fixture()
assert {:error, %Ecto.Changeset{}} = Forums.update_thread(thread, @invalid_attrs)
assert thread == Forums.get_thread!(thread.id)
end
test "delete_thread/1 deletes the thread" do
thread = thread_fixture()
assert {:ok, %Thread{}} = Forums.delete_thread(thread)
assert_raise Ecto.NoResultsError, fn -> Forums.get_thread!(thread.id) end
end
test "change_thread/1 returns a thread changeset" do
thread = thread_fixture()
assert %Ecto.Changeset{} = Forums.change_thread(thread)
end
end
end