alias changeset

This commit is contained in:
shibao 2022-02-01 00:22:44 -05:00
parent a6a9994b97
commit 3e73f33a6d
11 changed files with 53 additions and 44 deletions

View File

@ -46,7 +46,7 @@ defmodule Cannery.Ammo do
{:ok, %AmmoType{}}
iex> create_ammo_type(%{field: bad_value})
{:error, %Ecto.Changeset{}}
{:error, %Changeset{}}
"""
@spec create_ammo_type(attrs :: map()) ::
@ -63,7 +63,7 @@ defmodule Cannery.Ammo do
{:ok, %AmmoType{}}
iex> update_ammo_type(ammo_type, %{field: bad_value})
{:error, %Ecto.Changeset{}}
{:error, %Changeset{}}
"""
@spec update_ammo_type(AmmoType.t(), attrs :: map()) ::
@ -80,7 +80,7 @@ defmodule Cannery.Ammo do
{:ok, %AmmoType{}}
iex> delete_ammo_type(ammo_type)
{:error, %Ecto.Changeset{}}
{:error, %Changeset{}}
"""
@spec delete_ammo_type(AmmoType.t()) ::
@ -100,12 +100,12 @@ defmodule Cannery.Ammo do
def delete_ammo_type!(%AmmoType{} = ammo_type), do: ammo_type |> Repo.delete!()
@doc """
Returns an `%Ecto.Changeset{}` for tracking ammo_type changes.
Returns an `%Changeset{}` for tracking ammo_type changes.
## Examples
iex> change_ammo_type(ammo_type)
%Ecto.Changeset{data: %AmmoType{}}
%Changeset{data: %AmmoType{}}
"""
@spec change_ammo_type(AmmoType.t() | AmmoType.new_ammo_type()) ::
@ -160,7 +160,7 @@ defmodule Cannery.Ammo do
{:ok, %AmmoGroup{}}
iex> create_ammo_group(%{field: bad_value})
{:error, %Ecto.Changeset{}}
{:error, %Changeset{}}
"""
@spec create_ammo_group(attrs :: map()) ::
@ -177,7 +177,7 @@ defmodule Cannery.Ammo do
{:ok, %AmmoGroup{}}
iex> update_ammo_group(ammo_group, %{field: bad_value})
{:error, %Ecto.Changeset{}}
{:error, %Changeset{}}
"""
@spec update_ammo_group(AmmoGroup.t(), attrs :: map()) ::
@ -194,7 +194,7 @@ defmodule Cannery.Ammo do
{:ok, %AmmoGroup{}}
iex> delete_ammo_group(ammo_group)
{:error, %Ecto.Changeset{}}
{:error, %Changeset{}}
"""
@spec delete_ammo_group(AmmoGroup.t()) ::
@ -214,12 +214,12 @@ defmodule Cannery.Ammo do
def delete_ammo_group!(%AmmoGroup{} = ammo_group), do: ammo_group |> Repo.delete!()
@doc """
Returns an `%Ecto.Changeset{}` for tracking ammo_group changes.
Returns an `%Changeset{}` for tracking ammo_group changes.
## Examples
iex> change_ammo_group(ammo_group)
%Ecto.Changeset{data: %AmmoGroup{}}
%Changeset{data: %AmmoGroup{}}
"""
@spec change_ammo_group(AmmoGroup.t()) :: Changeset.t(AmmoGroup.t())

View File

@ -6,7 +6,7 @@ defmodule Cannery.Containers do
import Ecto.Query, warn: false
alias Cannery.{Accounts.User, Repo, Tags.Tag}
alias Cannery.Containers.{Container, ContainerTag}
alias Ecto.{Changeset}
alias Ecto.Changeset
@doc """
Returns the list of containers.
@ -47,7 +47,7 @@ defmodule Cannery.Containers do
{:ok, %Container{}}
iex> create_container(%{field: bad_value})
{:error, %Ecto.Changeset{}}
{:error, %Changeset{}}
"""
@spec create_container(attrs :: map()) ::
@ -65,7 +65,7 @@ defmodule Cannery.Containers do
{:ok, %Container{}}
iex> update_container(container, %{field: bad_value})
{:error, %Ecto.Changeset{}}
{:error, %Changeset{}}
"""
@spec update_container(Container.t(), attrs :: map()) ::
@ -83,7 +83,7 @@ defmodule Cannery.Containers do
{:ok, %Container{}}
iex> delete_container(container)
{:error, %Ecto.Changeset{}}
{:error, %Changeset{}}
"""
@spec delete_container(Container.t()) ::
@ -103,15 +103,15 @@ defmodule Cannery.Containers do
def delete_container!(container), do: container |> Repo.delete!()
@doc """
Returns an `%Ecto.Changeset{}` for tracking container changes.
Returns an `%Changeset{}` for tracking container changes.
## Examples
iex> change_container(container)
%Ecto.Changeset{data: %Container{}}
%Changeset{data: %Container{}}
iex> change_container(%Ecto.Changeset{})
%Ecto.Changeset{data: %Container{}}
iex> change_container(%Changeset{})
%Changeset{data: %Container{}}
"""
@spec change_container(Container.t() | Container.new_container()) ::

View File

@ -6,6 +6,7 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do
use CanneryWeb, :live_component
alias Cannery.Ammo
alias Ecto.Changeset
@impl true
def update(%{ammo_type: ammo_type} = assigns, socket) do
@ -104,7 +105,7 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do
|> put_flash(:info, "Ammo type updated successfully")
|> push_redirect(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:error, %Changeset{} = changeset} ->
{:noreply, socket |> assign(:changeset, changeset)}
end
end
@ -117,7 +118,7 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do
|> put_flash(:info, "Ammo type created successfully")
|> push_redirect(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:error, %Changeset{} = changeset} ->
{:noreply, socket |> assign(changeset: changeset)}
end
end

View File

@ -6,6 +6,7 @@ defmodule CanneryWeb.ContainerLive.FormComponent do
use CanneryWeb, :live_component
alias Cannery.Containers
alias Ecto.Changeset
@impl true
def update(%{container: container} = assigns, socket) do
@ -97,7 +98,7 @@ defmodule CanneryWeb.ContainerLive.FormComponent do
|> put_flash(:info, "Container updated successfully")
|> push_redirect(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:error, %Changeset{} = changeset} ->
{:noreply, socket |> assign(:changeset, changeset)}
end
end
@ -110,7 +111,7 @@ defmodule CanneryWeb.ContainerLive.FormComponent do
|> put_flash(:info, "Container created successfully")
|> push_redirect(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:error, %Changeset{} = changeset} ->
{:noreply, socket |> assign(changeset: changeset)}
end
end

View File

@ -6,6 +6,7 @@ defmodule CanneryWeb.InviteLive.FormComponent do
use CanneryWeb, :live_component
alias Cannery.Invites
alias Ecto.Changeset
@impl true
def update(%{invite: invite} = assigns, socket) do
@ -74,7 +75,7 @@ defmodule CanneryWeb.InviteLive.FormComponent do
|> put_flash(:info, "Invite updated successfully")
|> push_redirect(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:error, %Changeset{} = changeset} ->
{:noreply, assign(socket, :changeset, changeset)}
end
end
@ -87,7 +88,7 @@ defmodule CanneryWeb.InviteLive.FormComponent do
|> put_flash(:info, "Invite created successfully")
|> push_redirect(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:error, %Changeset{} = changeset} ->
{:noreply, assign(socket, changeset: changeset)}
end
end

View File

@ -6,6 +6,7 @@ defmodule CanneryWeb.TagLive.FormComponent do
use CanneryWeb, :live_component
alias Cannery.Tags
alias Ecto.Changeset
@impl true
def update(%{tag: tag} = assigns, socket) do
@ -86,7 +87,7 @@ defmodule CanneryWeb.TagLive.FormComponent do
|> put_flash(:info, "Tag updated successfully")
|> push_redirect(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:error, %Changeset{} = changeset} ->
{:noreply, socket |> assign(:changeset, changeset)}
end
end
@ -99,7 +100,7 @@ defmodule CanneryWeb.TagLive.FormComponent do
|> put_flash(:info, "Tag created successfully")
|> push_redirect(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:error, %Changeset{} = changeset} ->
{:noreply, socket |> assign(changeset: changeset)}
end
end

View File

@ -4,6 +4,7 @@ defmodule Cannery.AccountsTest do
alias Cannery.Accounts
import Cannery.AccountsFixtures
alias Cannery.Accounts.{User, UserToken}
alias Ecto.Changeset
describe "get_user_by_email/1" do
test "does not return the user if the email does not exist" do
@ -95,7 +96,7 @@ defmodule Cannery.AccountsTest do
describe "change_user_registration/2" do
test "returns a changeset" do
assert %Ecto.Changeset{} = changeset = Accounts.change_user_registration(%User{})
assert %Changeset{} = changeset = Accounts.change_user_registration(%User{})
assert changeset.required == [:password, :email]
end
@ -115,7 +116,7 @@ defmodule Cannery.AccountsTest do
describe "change_user_email/2" do
test "returns a user changeset" do
assert %Ecto.Changeset{} = changeset = Accounts.change_user_email(%User{})
assert %Changeset{} = changeset = Accounts.change_user_email(%User{})
assert changeset.required == [:email]
end
end
@ -234,7 +235,7 @@ defmodule Cannery.AccountsTest do
describe "change_user_password/2" do
test "returns a user changeset" do
assert %Ecto.Changeset{} = changeset = Accounts.change_user_password(%User{})
assert %Changeset{} = changeset = Accounts.change_user_password(%User{})
assert changeset.required == [:password]
end

View File

@ -2,6 +2,7 @@ defmodule Cannery.AmmoTest do
use Cannery.DataCase
alias Cannery.Ammo
alias Ecto.Changeset
describe "ammo_types" do
alias Cannery.Ammo.AmmoType
@ -61,7 +62,7 @@ defmodule Cannery.AmmoTest do
end
test "create_ammo_type/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Ammo.create_ammo_type(@invalid_attrs)
assert {:error, %Changeset{}} = Ammo.create_ammo_type(@invalid_attrs)
end
test "update_ammo_type/2 with valid data updates the ammo_type" do
@ -77,7 +78,7 @@ defmodule Cannery.AmmoTest do
test "update_ammo_type/2 with invalid data returns error changeset" do
ammo_type = ammo_type_fixture()
assert {:error, %Ecto.Changeset{}} = Ammo.update_ammo_type(ammo_type, @invalid_attrs)
assert {:error, %Changeset{}} = Ammo.update_ammo_type(ammo_type, @invalid_attrs)
assert ammo_type == Ammo.get_ammo_type!(ammo_type.id)
end
@ -89,7 +90,7 @@ defmodule Cannery.AmmoTest do
test "change_ammo_type/1 returns a ammo_type changeset" do
ammo_type = ammo_type_fixture()
assert %Ecto.Changeset{} = Ammo.change_ammo_type(ammo_type)
assert %Changeset{} = Ammo.change_ammo_type(ammo_type)
end
end
@ -127,7 +128,7 @@ defmodule Cannery.AmmoTest do
end
test "create_ammo_group/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Ammo.create_ammo_group(@invalid_attrs)
assert {:error, %Changeset{}} = Ammo.create_ammo_group(@invalid_attrs)
end
test "update_ammo_group/2 with valid data updates the ammo_group" do
@ -140,7 +141,7 @@ defmodule Cannery.AmmoTest do
test "update_ammo_group/2 with invalid data returns error changeset" do
ammo_group = ammo_group_fixture()
assert {:error, %Ecto.Changeset{}} = Ammo.update_ammo_group(ammo_group, @invalid_attrs)
assert {:error, %Changeset{}} = Ammo.update_ammo_group(ammo_group, @invalid_attrs)
assert ammo_group == Ammo.get_ammo_group!(ammo_group.id)
end
@ -152,7 +153,7 @@ defmodule Cannery.AmmoTest do
test "change_ammo_group/1 returns a ammo_group changeset" do
ammo_group = ammo_group_fixture()
assert %Ecto.Changeset{} = Ammo.change_ammo_group(ammo_group)
assert %Changeset{} = Ammo.change_ammo_group(ammo_group)
end
end
end

View File

@ -2,6 +2,7 @@ defmodule Cannery.ContainersTest do
use Cannery.DataCase
alias Cannery.Containers
alias Ecto.Changeset
describe "containers" do
alias Cannery.Containers.Container
@ -48,7 +49,7 @@ defmodule Cannery.ContainersTest do
end
test "create_container/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Containers.create_container(@invalid_attrs)
assert {:error, %Changeset{}} = Containers.create_container(@invalid_attrs)
end
test "update_container/2 with valid data updates the container" do
@ -65,7 +66,7 @@ defmodule Cannery.ContainersTest do
test "update_container/2 with invalid data returns error changeset" do
container = container_fixture()
assert {:error, %Ecto.Changeset{}} = Containers.update_container(container, @invalid_attrs)
assert {:error, %Changeset{}} = Containers.update_container(container, @invalid_attrs)
assert container == Containers.get_container!(container.id)
end
@ -77,7 +78,7 @@ defmodule Cannery.ContainersTest do
test "change_container/1 returns a container changeset" do
container = container_fixture()
assert %Ecto.Changeset{} = Containers.change_container(container)
assert %Changeset{} = Containers.change_container(container)
end
end
end

View File

@ -2,6 +2,7 @@ defmodule Cannery.InvitesTest do
use Cannery.DataCase
alias Cannery.{AccountsFixtures, Invites}
alias Ecto.Changeset
describe "invites" do
alias Cannery.Invites.Invite
@ -44,7 +45,7 @@ defmodule Cannery.InvitesTest do
end
test "create_invite/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Invites.create_invite(@invalid_attrs)
assert {:error, %Changeset{}} = Invites.create_invite(@invalid_attrs)
end
test "update_invite/2 with valid data updates the invite" do
@ -56,7 +57,7 @@ defmodule Cannery.InvitesTest do
test "update_invite/2 with invalid data returns error changeset" do
invite = invite_fixture()
assert {:error, %Ecto.Changeset{}} = Invites.update_invite(invite, @invalid_attrs)
assert {:error, %Changeset{}} = Invites.update_invite(invite, @invalid_attrs)
assert invite == Invites.get_invite!(invite.id)
end
@ -68,7 +69,7 @@ defmodule Cannery.InvitesTest do
test "change_invite/1 returns a invite changeset" do
invite = invite_fixture()
assert %Ecto.Changeset{} = Invites.change_invite(invite)
assert %Changeset{} = Invites.change_invite(invite)
end
end
end

View File

@ -2,6 +2,7 @@ defmodule Cannery.TagsTest do
use Cannery.DataCase
alias Cannery.{AccountsFixtures, Tags}
alias Ecto.Changeset
describe "tags" do
alias Cannery.Tags.Tag
@ -52,7 +53,7 @@ defmodule Cannery.TagsTest do
end
test "create_tag/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Tags.create_tag(@invalid_attrs)
assert {:error, %Changeset{}} = Tags.create_tag(@invalid_attrs)
end
test "update_tag/2 with valid data updates the tag" do
@ -65,7 +66,7 @@ defmodule Cannery.TagsTest do
test "update_tag/2 with invalid data returns error changeset" do
tag = tag_fixture()
assert {:error, %Ecto.Changeset{}} = Tags.update_tag(tag, @invalid_attrs)
assert {:error, %Changeset{}} = Tags.update_tag(tag, @invalid_attrs)
assert tag == Tags.get_tag!(tag.id)
end
@ -77,7 +78,7 @@ defmodule Cannery.TagsTest do
test "change_tag/1 returns a tag changeset" do
tag = tag_fixture()
assert %Ecto.Changeset{} = Tags.change_tag(tag)
assert %Changeset{} = Tags.change_tag(tag)
end
end
end