fix tests
This commit is contained in:
		| @@ -9,17 +9,16 @@ config :bcrypt_elixir, :log_rounds, 1 | |||||||
| # to provide built-in test partitioning in CI environment. | # to provide built-in test partitioning in CI environment. | ||||||
| # Run `mix help test` for more information. | # Run `mix help test` for more information. | ||||||
| config :cannery, Cannery.Repo, | config :cannery, Cannery.Repo, | ||||||
|   username: "postgres", |   url: | ||||||
|   password: "postgres", |     System.get_env("DATABASE_URL") || | ||||||
|   hostname: "localhost", |       "ecto://postgres:postgres@localhost/cannery_test#{System.get_env("MIX_TEST_PARTITION")}", | ||||||
|   database: "cannery_test#{System.get_env("MIX_TEST_PARTITION")}", |  | ||||||
|   pool: Ecto.Adapters.SQL.Sandbox, |   pool: Ecto.Adapters.SQL.Sandbox, | ||||||
|   pool_size: 10 |   pool_size: 10 | ||||||
|  |  | ||||||
| # We don't run a server during test. If one is required, | # We don't run a server during test. If one is required, | ||||||
| # you can enable the server option below. | # you can enable the server option below. | ||||||
| config :cannery, CanneryWeb.Endpoint, | config :cannery, CanneryWeb.Endpoint, | ||||||
|   http: [ip: {127, 0, 0, 1}, port: 4002], |   http: [ip: {0, 0, 0, 0}, port: 4002], | ||||||
|   secret_key_base: "S3qq9QtUdsFtlYej+HTjAVN95uP5i5tf2sPYINWSQfCKJghFj2B1+wTAoljZyHOK", |   secret_key_base: "S3qq9QtUdsFtlYej+HTjAVN95uP5i5tf2sPYINWSQfCKJghFj2B1+wTAoljZyHOK", | ||||||
|   server: false |   server: false | ||||||
|  |  | ||||||
|   | |||||||
| @@ -96,7 +96,8 @@ defmodule Cannery.Invites do | |||||||
|       {:error, %Ecto.Changeset{}} |       {:error, %Ecto.Changeset{}} | ||||||
|  |  | ||||||
|   """ |   """ | ||||||
|   @spec create_invite(Accounts.User.t() | Ecto.UUID.t(), map()) :: Invite.t() |   @spec create_invite(user_or_user_id :: Accounts.User.t() | Ecto.UUID.t(), attrs :: map()) :: | ||||||
|  |           Invite.t() | ||||||
|   def create_invite(%{id: user_id}, attrs) do |   def create_invite(%{id: user_id}, attrs) do | ||||||
|     create_invite(user_id, attrs) |     create_invite(user_id, attrs) | ||||||
|   end |   end | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -6,9 +6,30 @@ defmodule Cannery.AmmoTest do | |||||||
|   describe "ammo_types" do |   describe "ammo_types" do | ||||||
|     alias Cannery.Ammo.AmmoType |     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} |     @valid_attrs %{ | ||||||
|     @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} |       "bullet_type" => "some bullet_type", | ||||||
|     @invalid_attrs %{bullet_type: nil, case_material: nil, desc: nil, manufacturer: nil, name: nil, weight: nil} |       "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 |     def ammo_type_fixture(attrs \\ %{}) do | ||||||
|       {:ok, ammo_type} = |       {:ok, ammo_type} = | ||||||
|   | |||||||
| @@ -6,8 +6,18 @@ defmodule Cannery.ContainersTest do | |||||||
|   describe "containers" do |   describe "containers" do | ||||||
|     alias Cannery.Containers.Container |     alias Cannery.Containers.Container | ||||||
|  |  | ||||||
|     @valid_attrs %{desc: "some desc", location: "some location", name: "some name", type: "some type"} |     @valid_attrs %{ | ||||||
|     @update_attrs %{desc: "some updated desc", location: "some updated location", name: "some updated name", type: "some updated type"} |       "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} |     @invalid_attrs %{desc: nil, location: nil, name: nil, type: nil} | ||||||
|  |  | ||||||
|     def container_fixture(attrs \\ %{}) do |     def container_fixture(attrs \\ %{}) do | ||||||
| @@ -43,7 +53,10 @@ defmodule Cannery.ContainersTest do | |||||||
|  |  | ||||||
|     test "update_container/2 with valid data updates the container" do |     test "update_container/2 with valid data updates the container" do | ||||||
|       container = container_fixture() |       container = container_fixture() | ||||||
|       assert {:ok, %Container{} = container} = Containers.update_container(container, @update_attrs) |  | ||||||
|  |       assert {:ok, %Container{} = container} = | ||||||
|  |                Containers.update_container(container, @update_attrs) | ||||||
|  |  | ||||||
|       assert container.desc == "some updated desc" |       assert container.desc == "some updated desc" | ||||||
|       assert container.location == "some updated location" |       assert container.location == "some updated location" | ||||||
|       assert container.name == "some updated name" |       assert container.name == "some updated name" | ||||||
|   | |||||||
| @@ -1,20 +1,28 @@ | |||||||
| defmodule Cannery.InvitesTest do | defmodule Cannery.InvitesTest do | ||||||
|   use Cannery.DataCase |   use Cannery.DataCase | ||||||
|  |  | ||||||
|   alias Cannery.Invites |   alias Cannery.{AccountsFixtures, Invites} | ||||||
|  |  | ||||||
|   describe "invites" do |   describe "invites" do | ||||||
|     alias Cannery.Invites.Invite |     alias Cannery.Invites.Invite | ||||||
|  |  | ||||||
|     @valid_attrs %{name: "some name", token: "some token"} |     @valid_attrs %{ | ||||||
|     @update_attrs %{name: "some updated name", token: "some updated token"} |       "name" => "some name", | ||||||
|     @invalid_attrs %{name: nil, token: nil} |       "token" => "some token" | ||||||
|  |     } | ||||||
|  |     @update_attrs %{ | ||||||
|  |       "name" => "some updated name", | ||||||
|  |       "token" => "some updated token" | ||||||
|  |     } | ||||||
|  |     @invalid_attrs %{ | ||||||
|  |       "name" => nil, | ||||||
|  |       "token" => nil | ||||||
|  |     } | ||||||
|  |  | ||||||
|     def invite_fixture(attrs \\ %{}) do |     def invite_fixture(attrs \\ %{}) do | ||||||
|       {:ok, invite} = |       {:ok, invite} = | ||||||
|         attrs |         AccountsFixtures.user_fixture() | ||||||
|         |> Enum.into(@valid_attrs) |         |> Invites.create_invite(attrs |> Enum.into(@valid_attrs)) | ||||||
|         |> Invites.create_invite() |  | ||||||
|  |  | ||||||
|       invite |       invite | ||||||
|     end |     end | ||||||
|   | |||||||
| @@ -1,18 +1,33 @@ | |||||||
| defmodule Cannery.TagsTest do | defmodule Cannery.TagsTest do | ||||||
|   use Cannery.DataCase |   use Cannery.DataCase | ||||||
|  |  | ||||||
|   alias Cannery.Tags |   alias Cannery.{AccountsFixtures, Tags} | ||||||
|  |  | ||||||
|   describe "tags" do |   describe "tags" do | ||||||
|     alias Cannery.Tags.Tag |     alias Cannery.Tags.Tag | ||||||
|  |  | ||||||
|     @valid_attrs %{bg_color: "some bg-color", name: "some name", text_color: "some text-color"} |     @valid_attrs %{ | ||||||
|     @update_attrs %{bg_color: "some updated bg-color", name: "some updated name", text_color: "some updated text-color"} |       "bg_color" => "some bg-color", | ||||||
|     @invalid_attrs %{bg_color: nil, name: nil, text_color: nil} |       "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 |     def tag_fixture(attrs \\ %{}) do | ||||||
|  |       %{id: user_id} = AccountsFixtures.user_fixture() | ||||||
|  |  | ||||||
|       {:ok, tag} = |       {:ok, tag} = | ||||||
|         attrs |         attrs | ||||||
|  |         |> Map.put("user_id", user_id) | ||||||
|         |> Enum.into(@valid_attrs) |         |> Enum.into(@valid_attrs) | ||||||
|         |> Tags.create_tag() |         |> Tags.create_tag() | ||||||
|  |  | ||||||
| @@ -31,9 +46,9 @@ defmodule Cannery.TagsTest do | |||||||
|  |  | ||||||
|     test "create_tag/1 with valid data creates a tag" do |     test "create_tag/1 with valid data creates a tag" do | ||||||
|       assert {:ok, %Tag{} = tag} = Tags.create_tag(@valid_attrs) |       assert {:ok, %Tag{} = tag} = Tags.create_tag(@valid_attrs) | ||||||
|       assert tag.bg-color == "some bg-color" |       assert tag.bg_color == "some bg-color" | ||||||
|       assert tag.name == "some name" |       assert tag.name == "some name" | ||||||
|       assert tag.text-color == "some text-color" |       assert tag.text_color == "some text-color" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "create_tag/1 with invalid data returns error changeset" do |     test "create_tag/1 with invalid data returns error changeset" do | ||||||
| @@ -43,9 +58,9 @@ defmodule Cannery.TagsTest do | |||||||
|     test "update_tag/2 with valid data updates the tag" do |     test "update_tag/2 with valid data updates the tag" do | ||||||
|       tag = tag_fixture() |       tag = tag_fixture() | ||||||
|       assert {:ok, %Tag{} = tag} = Tags.update_tag(tag, @update_attrs) |       assert {:ok, %Tag{} = tag} = Tags.update_tag(tag, @update_attrs) | ||||||
|       assert tag.bg-color == "some updated bg-color" |       assert tag.bg_color == "some updated bg-color" | ||||||
|       assert tag.name == "some updated name" |       assert tag.name == "some updated name" | ||||||
|       assert tag.text-color == "some updated text-color" |       assert tag.text_color == "some updated text-color" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "update_tag/2 with invalid data returns error changeset" do |     test "update_tag/2 with invalid data returns error changeset" do | ||||||
|   | |||||||
| @@ -5,9 +5,30 @@ defmodule CanneryWeb.AmmoTypeLiveTest do | |||||||
|  |  | ||||||
|   alias Cannery.Ammo |   alias Cannery.Ammo | ||||||
|  |  | ||||||
|   @create_attrs %{bullet_type: "some bullet_type", case_material: "some case_material", desc: "some desc", manufacturer: "some manufacturer", name: "some name", weight: 120.5} |   @create_attrs %{ | ||||||
|   @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} |     "bullet_type" => "some bullet_type", | ||||||
|   @invalid_attrs %{bullet_type: nil, case_material: nil, desc: nil, manufacturer: nil, name: nil, weight: nil} |     "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 | ||||||
|  |   } | ||||||
|  |  | ||||||
|   defp fixture(:ammo_type) do |   defp fixture(:ammo_type) do | ||||||
|     {:ok, ammo_type} = Ammo.create_ammo_type(@create_attrs) |     {:ok, ammo_type} = Ammo.create_ammo_type(@create_attrs) | ||||||
|   | |||||||
| @@ -5,8 +5,18 @@ defmodule CanneryWeb.ContainerLiveTest do | |||||||
|  |  | ||||||
|   alias Cannery.Containers |   alias Cannery.Containers | ||||||
|  |  | ||||||
|   @create_attrs %{desc: "some desc", location: "some location", name: "some name", type: "some type"} |   @create_attrs %{ | ||||||
|   @update_attrs %{desc: "some updated desc", location: "some updated location", name: "some updated name", type: "some updated type"} |     "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} |   @invalid_attrs %{desc: nil, location: nil, name: nil, type: nil} | ||||||
|  |  | ||||||
|   defp fixture(:container) do |   defp fixture(:container) do | ||||||
|   | |||||||
| @@ -5,9 +5,21 @@ defmodule CanneryWeb.TagLiveTest do | |||||||
|  |  | ||||||
|   alias Cannery.Tags |   alias Cannery.Tags | ||||||
|  |  | ||||||
|   @create_attrs %{bg_color: "some bg-color", name: "some name", text_color: "some text-color"} |   @create_attrs %{ | ||||||
|   @update_attrs %{bg_color: "some updated bg-color", name: "some updated name", text_color: "some updated text-color"} |     "bg_color" => "some bg-color", | ||||||
|   @invalid_attrs %{bg_color: nil, name: nil, text_color: nil} |     "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 | ||||||
|  |   } | ||||||
|  |  | ||||||
|   defp fixture(:tag) do |   defp fixture(:tag) do | ||||||
|     {:ok, tag} = Tags.create_tag(@create_attrs) |     {:ok, tag} = Tags.create_tag(@create_attrs) | ||||||
| @@ -26,7 +38,7 @@ defmodule CanneryWeb.TagLiveTest do | |||||||
|       {:ok, _index_live, html} = live(conn, Routes.tag_index_path(conn, :index)) |       {:ok, _index_live, html} = live(conn, Routes.tag_index_path(conn, :index)) | ||||||
|  |  | ||||||
|       assert html =~ "Listing Tags" |       assert html =~ "Listing Tags" | ||||||
|       assert html =~ tag.bg-color |       assert html =~ tag.bg_color | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "saves new tag", %{conn: conn} do |     test "saves new tag", %{conn: conn} do | ||||||
| @@ -88,7 +100,7 @@ defmodule CanneryWeb.TagLiveTest do | |||||||
|       {:ok, _show_live, html} = live(conn, Routes.tag_show_path(conn, :show, tag)) |       {:ok, _show_live, html} = live(conn, Routes.tag_show_path(conn, :show, tag)) | ||||||
|  |  | ||||||
|       assert html =~ "Show Tag" |       assert html =~ "Show Tag" | ||||||
|       assert html =~ tag.bg-color |       assert html =~ tag.bg_color | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "updates tag within modal", %{conn: conn, tag: tag} do |     test "updates tag within modal", %{conn: conn, tag: tag} do | ||||||
|   | |||||||
| @@ -4,9 +4,13 @@ defmodule Cannery.AccountsFixtures do | |||||||
|   entities via the `Cannery.Accounts` context. |   entities via the `Cannery.Accounts` context. | ||||||
|   """ |   """ | ||||||
|  |  | ||||||
|  |   alias Cannery.{Accounts} | ||||||
|  |  | ||||||
|   def unique_user_email, do: "user#{System.unique_integer()}@example.com" |   def unique_user_email, do: "user#{System.unique_integer()}@example.com" | ||||||
|   def valid_user_password, do: "hello world!" |   def valid_user_password, do: "hello world!" | ||||||
|  |  | ||||||
|  |   @spec user_fixture() :: Accounts.User.t() | ||||||
|  |   @spec user_fixture(attrs :: map()) :: Accounts.User.t() | ||||||
|   def user_fixture(attrs \\ %{}) do |   def user_fixture(attrs \\ %{}) do | ||||||
|     {:ok, user} = |     {:ok, user} = | ||||||
|       attrs |       attrs | ||||||
| @@ -14,7 +18,7 @@ defmodule Cannery.AccountsFixtures do | |||||||
|         email: unique_user_email(), |         email: unique_user_email(), | ||||||
|         password: valid_user_password() |         password: valid_user_password() | ||||||
|       }) |       }) | ||||||
|       |> Cannery.Accounts.register_user() |       |> Accounts.register_user() | ||||||
|  |  | ||||||
|     user |     user | ||||||
|   end |   end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user