From b122253b9bae1acc2aca2e3d28d8ce90ed80f7f6 Mon Sep 17 00:00:00 2001 From: shibao Date: Thu, 30 Mar 2023 00:07:38 -0400 Subject: [PATCH] improve tests --- test/cannery/ammo_test.exs | 8 ++++---- test/support/fixtures.ex | 42 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/test/cannery/ammo_test.exs b/test/cannery/ammo_test.exs index fad8f0a..28823ec 100644 --- a/test/cannery/ammo_test.exs +++ b/test/cannery/ammo_test.exs @@ -43,7 +43,7 @@ defmodule Cannery.AmmoTest do name: "bullets", class: :rifle, desc: "has some pews in it", - grains: 5 + grains: 53_453 } |> ammo_type_fixture(current_user) @@ -51,7 +51,7 @@ defmodule Cannery.AmmoTest do %{ name: "hollows", class: :shotgun, - grains: 3 + grains: 3_234_234 } |> ammo_type_fixture(current_user) @@ -131,8 +131,8 @@ defmodule Cannery.AmmoTest do assert Ammo.list_ammo_types("shell", current_user, :all) == [pistol_ammo_type] # grains (integer) - assert Ammo.list_ammo_types("5", current_user, :all) == [rifle_ammo_type] - assert Ammo.list_ammo_types("3", current_user, :all) == [shotgun_ammo_type] + assert Ammo.list_ammo_types("53453", current_user, :all) == [rifle_ammo_type] + assert Ammo.list_ammo_types("3234234", current_user, :all) == [shotgun_ammo_type] # tracer (boolean) assert Ammo.list_ammo_types("tracer", current_user, :all) == [pistol_ammo_type] diff --git a/test/support/fixtures.ex b/test/support/fixtures.ex index cde2d7f..5fdde9f 100644 --- a/test/support/fixtures.ex +++ b/test/support/fixtures.ex @@ -91,7 +91,12 @@ defmodule Cannery.Fixtures do @spec container_fixture(attrs :: map(), User.t()) :: Container.t() def container_fixture(attrs \\ %{}, %User{} = user) do attrs - |> Enum.into(%{name: random_string(), type: "Ammo can"}) + |> Enum.into(%{ + name: random_string(), + type: "Ammo can", + location: random_string(), + desc: random_string() + }) |> Containers.create_container(user) |> unwrap_ok_tuple() end @@ -103,7 +108,40 @@ defmodule Cannery.Fixtures do @spec ammo_type_fixture(attrs :: map(), User.t()) :: AmmoType.t() def ammo_type_fixture(attrs \\ %{}, %User{} = user) do attrs - |> Enum.into(%{name: random_string(), class: :rifle}) + |> Enum.into(%{ + name: random_string(), + class: :rifle, + desc: random_string(), + bullet_type: random_string(), + bullet_core: random_string(), + cartridge: random_string(), + caliber: random_string(), + case_material: random_string(), + jacket_type: random_string(), + muzzle_velocity: 3, + powder_type: random_string(), + powder_grains_per_charge: 5, + grains: 7, + pressure: random_string(), + primer_type: random_string(), + firing_type: random_string(), + wadding: random_string(), + shot_type: random_string(), + shot_material: random_string(), + shot_size: random_string(), + unfired_length: random_string(), + brass_height: random_string(), + chamber_size: random_string(), + load_grains: 9, + shot_charge_weight: random_string(), + dram_equivalent: random_string(), + tracer: false, + incendiary: false, + blank: false, + corrosive: false, + manufacturer: random_string(), + upc: random_string() + }) |> Ammo.create_ammo_type(user) |> unwrap_ok_tuple() end