add models, context and liveviews
This commit is contained in:
137
test/cannery/ammo_test.exs
Normal file
137
test/cannery/ammo_test.exs
Normal file
@ -0,0 +1,137 @@
|
||||
defmodule Cannery.AmmoTest do
|
||||
use Cannery.DataCase
|
||||
|
||||
alias Cannery.Ammo
|
||||
|
||||
describe "ammo_types" do
|
||||
alias Cannery.Ammo.AmmoType
|
||||
|
||||
@valid_attrs %{bullet_type: "some bullet_type", case_material: "some case_material", desc: "some desc", manufacturer: "some manufacturer", name: "some name", weight: 120.5}
|
||||
@update_attrs %{bullet_type: "some updated bullet_type", case_material: "some updated case_material", desc: "some updated desc", manufacturer: "some updated manufacturer", name: "some updated name", weight: 456.7}
|
||||
@invalid_attrs %{bullet_type: nil, case_material: nil, desc: nil, manufacturer: nil, name: nil, weight: nil}
|
||||
|
||||
def ammo_type_fixture(attrs \\ %{}) do
|
||||
{:ok, ammo_type} =
|
||||
attrs
|
||||
|> Enum.into(@valid_attrs)
|
||||
|> Ammo.create_ammo_type()
|
||||
|
||||
ammo_type
|
||||
end
|
||||
|
||||
test "list_ammo_types/0 returns all ammo_types" do
|
||||
ammo_type = ammo_type_fixture()
|
||||
assert Ammo.list_ammo_types() == [ammo_type]
|
||||
end
|
||||
|
||||
test "get_ammo_type!/1 returns the ammo_type with given id" do
|
||||
ammo_type = ammo_type_fixture()
|
||||
assert Ammo.get_ammo_type!(ammo_type.id) == ammo_type
|
||||
end
|
||||
|
||||
test "create_ammo_type/1 with valid data creates a ammo_type" do
|
||||
assert {:ok, %AmmoType{} = ammo_type} = Ammo.create_ammo_type(@valid_attrs)
|
||||
assert ammo_type.bullet_type == "some bullet_type"
|
||||
assert ammo_type.case_material == "some case_material"
|
||||
assert ammo_type.desc == "some desc"
|
||||
assert ammo_type.manufacturer == "some manufacturer"
|
||||
assert ammo_type.name == "some name"
|
||||
assert ammo_type.weight == 120.5
|
||||
end
|
||||
|
||||
test "create_ammo_type/1 with invalid data returns error changeset" do
|
||||
assert {:error, %Ecto.Changeset{}} = Ammo.create_ammo_type(@invalid_attrs)
|
||||
end
|
||||
|
||||
test "update_ammo_type/2 with valid data updates the ammo_type" do
|
||||
ammo_type = ammo_type_fixture()
|
||||
assert {:ok, %AmmoType{} = ammo_type} = Ammo.update_ammo_type(ammo_type, @update_attrs)
|
||||
assert ammo_type.bullet_type == "some updated bullet_type"
|
||||
assert ammo_type.case_material == "some updated case_material"
|
||||
assert ammo_type.desc == "some updated desc"
|
||||
assert ammo_type.manufacturer == "some updated manufacturer"
|
||||
assert ammo_type.name == "some updated name"
|
||||
assert ammo_type.weight == 456.7
|
||||
end
|
||||
|
||||
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 ammo_type == Ammo.get_ammo_type!(ammo_type.id)
|
||||
end
|
||||
|
||||
test "delete_ammo_type/1 deletes the ammo_type" do
|
||||
ammo_type = ammo_type_fixture()
|
||||
assert {:ok, %AmmoType{}} = Ammo.delete_ammo_type(ammo_type)
|
||||
assert_raise Ecto.NoResultsError, fn -> Ammo.get_ammo_type!(ammo_type.id) end
|
||||
end
|
||||
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
describe "ammo_groups" do
|
||||
alias Cannery.Ammo.AmmoGroup
|
||||
|
||||
@valid_attrs %{count: 42, notes: "some notes", price_paid: 120.5}
|
||||
@update_attrs %{count: 43, notes: "some updated notes", price_paid: 456.7}
|
||||
@invalid_attrs %{count: nil, notes: nil, price_paid: nil}
|
||||
|
||||
def ammo_group_fixture(attrs \\ %{}) do
|
||||
{:ok, ammo_group} =
|
||||
attrs
|
||||
|> Enum.into(@valid_attrs)
|
||||
|> Ammo.create_ammo_group()
|
||||
|
||||
ammo_group
|
||||
end
|
||||
|
||||
test "list_ammo_groups/0 returns all ammo_groups" do
|
||||
ammo_group = ammo_group_fixture()
|
||||
assert Ammo.list_ammo_groups() == [ammo_group]
|
||||
end
|
||||
|
||||
test "get_ammo_group!/1 returns the ammo_group with given id" do
|
||||
ammo_group = ammo_group_fixture()
|
||||
assert Ammo.get_ammo_group!(ammo_group.id) == ammo_group
|
||||
end
|
||||
|
||||
test "create_ammo_group/1 with valid data creates a ammo_group" do
|
||||
assert {:ok, %AmmoGroup{} = ammo_group} = Ammo.create_ammo_group(@valid_attrs)
|
||||
assert ammo_group.count == 42
|
||||
assert ammo_group.notes == "some notes"
|
||||
assert ammo_group.price_paid == 120.5
|
||||
end
|
||||
|
||||
test "create_ammo_group/1 with invalid data returns error changeset" do
|
||||
assert {:error, %Ecto.Changeset{}} = Ammo.create_ammo_group(@invalid_attrs)
|
||||
end
|
||||
|
||||
test "update_ammo_group/2 with valid data updates the ammo_group" do
|
||||
ammo_group = ammo_group_fixture()
|
||||
assert {:ok, %AmmoGroup{} = ammo_group} = Ammo.update_ammo_group(ammo_group, @update_attrs)
|
||||
assert ammo_group.count == 43
|
||||
assert ammo_group.notes == "some updated notes"
|
||||
assert ammo_group.price_paid == 456.7
|
||||
end
|
||||
|
||||
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 ammo_group == Ammo.get_ammo_group!(ammo_group.id)
|
||||
end
|
||||
|
||||
test "delete_ammo_group/1 deletes the ammo_group" do
|
||||
ammo_group = ammo_group_fixture()
|
||||
assert {:ok, %AmmoGroup{}} = Ammo.delete_ammo_group(ammo_group)
|
||||
assert_raise Ecto.NoResultsError, fn -> Ammo.get_ammo_group!(ammo_group.id) end
|
||||
end
|
||||
|
||||
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)
|
||||
end
|
||||
end
|
||||
end
|
70
test/cannery/containers_test.exs
Normal file
70
test/cannery/containers_test.exs
Normal file
@ -0,0 +1,70 @@
|
||||
defmodule Cannery.ContainersTest do
|
||||
use Cannery.DataCase
|
||||
|
||||
alias Cannery.Containers
|
||||
|
||||
describe "containers" do
|
||||
alias Cannery.Containers.Container
|
||||
|
||||
@valid_attrs %{desc: "some desc", location: "some location", name: "some name", type: "some type"}
|
||||
@update_attrs %{desc: "some updated desc", location: "some updated location", name: "some updated name", type: "some updated type"}
|
||||
@invalid_attrs %{desc: nil, location: nil, name: nil, type: nil}
|
||||
|
||||
def container_fixture(attrs \\ %{}) do
|
||||
{:ok, container} =
|
||||
attrs
|
||||
|> Enum.into(@valid_attrs)
|
||||
|> Containers.create_container()
|
||||
|
||||
container
|
||||
end
|
||||
|
||||
test "list_containers/0 returns all containers" do
|
||||
container = container_fixture()
|
||||
assert Containers.list_containers() == [container]
|
||||
end
|
||||
|
||||
test "get_container!/1 returns the container with given id" do
|
||||
container = container_fixture()
|
||||
assert Containers.get_container!(container.id) == container
|
||||
end
|
||||
|
||||
test "create_container/1 with valid data creates a container" do
|
||||
assert {:ok, %Container{} = container} = Containers.create_container(@valid_attrs)
|
||||
assert container.desc == "some desc"
|
||||
assert container.location == "some location"
|
||||
assert container.name == "some name"
|
||||
assert container.type == "some type"
|
||||
end
|
||||
|
||||
test "create_container/1 with invalid data returns error changeset" do
|
||||
assert {:error, %Ecto.Changeset{}} = Containers.create_container(@invalid_attrs)
|
||||
end
|
||||
|
||||
test "update_container/2 with valid data updates the container" do
|
||||
container = container_fixture()
|
||||
assert {:ok, %Container{} = container} = Containers.update_container(container, @update_attrs)
|
||||
assert container.desc == "some updated desc"
|
||||
assert container.location == "some updated location"
|
||||
assert container.name == "some updated name"
|
||||
assert container.type == "some updated type"
|
||||
end
|
||||
|
||||
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 container == Containers.get_container!(container.id)
|
||||
end
|
||||
|
||||
test "delete_container/1 deletes the container" do
|
||||
container = container_fixture()
|
||||
assert {:ok, %Container{}} = Containers.delete_container(container)
|
||||
assert_raise Ecto.NoResultsError, fn -> Containers.get_container!(container.id) end
|
||||
end
|
||||
|
||||
test "change_container/1 returns a container changeset" do
|
||||
container = container_fixture()
|
||||
assert %Ecto.Changeset{} = Containers.change_container(container)
|
||||
end
|
||||
end
|
||||
end
|
68
test/cannery/tags_test.exs
Normal file
68
test/cannery/tags_test.exs
Normal file
@ -0,0 +1,68 @@
|
||||
defmodule Cannery.TagsTest do
|
||||
use Cannery.DataCase
|
||||
|
||||
alias Cannery.Tags
|
||||
|
||||
describe "tags" do
|
||||
alias Cannery.Tags.Tag
|
||||
|
||||
@valid_attrs %{"bg-color": "some bg-color", name: "some name", "text-color": "some text-color"}
|
||||
@update_attrs %{"bg-color": "some updated bg-color", name: "some updated name", "text-color": "some updated text-color"}
|
||||
@invalid_attrs %{"bg-color": nil, name: nil, "text-color": nil}
|
||||
|
||||
def tag_fixture(attrs \\ %{}) do
|
||||
{:ok, tag} =
|
||||
attrs
|
||||
|> Enum.into(@valid_attrs)
|
||||
|> Tags.create_tag()
|
||||
|
||||
tag
|
||||
end
|
||||
|
||||
test "list_tags/0 returns all tags" do
|
||||
tag = tag_fixture()
|
||||
assert Tags.list_tags() == [tag]
|
||||
end
|
||||
|
||||
test "get_tag!/1 returns the tag with given id" do
|
||||
tag = tag_fixture()
|
||||
assert Tags.get_tag!(tag.id) == tag
|
||||
end
|
||||
|
||||
test "create_tag/1 with valid data creates a tag" do
|
||||
assert {:ok, %Tag{} = tag} = Tags.create_tag(@valid_attrs)
|
||||
assert tag.bg-color == "some bg-color"
|
||||
assert tag.name == "some name"
|
||||
assert tag.text-color == "some text-color"
|
||||
end
|
||||
|
||||
test "create_tag/1 with invalid data returns error changeset" do
|
||||
assert {:error, %Ecto.Changeset{}} = Tags.create_tag(@invalid_attrs)
|
||||
end
|
||||
|
||||
test "update_tag/2 with valid data updates the tag" do
|
||||
tag = tag_fixture()
|
||||
assert {:ok, %Tag{} = tag} = Tags.update_tag(tag, @update_attrs)
|
||||
assert tag.bg-color == "some updated bg-color"
|
||||
assert tag.name == "some updated name"
|
||||
assert tag.text-color == "some updated text-color"
|
||||
end
|
||||
|
||||
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 tag == Tags.get_tag!(tag.id)
|
||||
end
|
||||
|
||||
test "delete_tag/1 deletes the tag" do
|
||||
tag = tag_fixture()
|
||||
assert {:ok, %Tag{}} = Tags.delete_tag(tag)
|
||||
assert_raise Ecto.NoResultsError, fn -> Tags.get_tag!(tag.id) end
|
||||
end
|
||||
|
||||
test "change_tag/1 returns a tag changeset" do
|
||||
tag = tag_fixture()
|
||||
assert %Ecto.Changeset{} = Tags.change_tag(tag)
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user