forked from shibao/cannery
improve tests
This commit is contained in:
parent
a68a16bf06
commit
b122253b9b
@ -43,7 +43,7 @@ defmodule Cannery.AmmoTest do
|
|||||||
name: "bullets",
|
name: "bullets",
|
||||||
class: :rifle,
|
class: :rifle,
|
||||||
desc: "has some pews in it",
|
desc: "has some pews in it",
|
||||||
grains: 5
|
grains: 53_453
|
||||||
}
|
}
|
||||||
|> ammo_type_fixture(current_user)
|
|> ammo_type_fixture(current_user)
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ defmodule Cannery.AmmoTest do
|
|||||||
%{
|
%{
|
||||||
name: "hollows",
|
name: "hollows",
|
||||||
class: :shotgun,
|
class: :shotgun,
|
||||||
grains: 3
|
grains: 3_234_234
|
||||||
}
|
}
|
||||||
|> ammo_type_fixture(current_user)
|
|> 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]
|
assert Ammo.list_ammo_types("shell", current_user, :all) == [pistol_ammo_type]
|
||||||
|
|
||||||
# grains (integer)
|
# grains (integer)
|
||||||
assert Ammo.list_ammo_types("5", current_user, :all) == [rifle_ammo_type]
|
assert Ammo.list_ammo_types("53453", current_user, :all) == [rifle_ammo_type]
|
||||||
assert Ammo.list_ammo_types("3", current_user, :all) == [shotgun_ammo_type]
|
assert Ammo.list_ammo_types("3234234", current_user, :all) == [shotgun_ammo_type]
|
||||||
|
|
||||||
# tracer (boolean)
|
# tracer (boolean)
|
||||||
assert Ammo.list_ammo_types("tracer", current_user, :all) == [pistol_ammo_type]
|
assert Ammo.list_ammo_types("tracer", current_user, :all) == [pistol_ammo_type]
|
||||||
|
@ -91,7 +91,12 @@ defmodule Cannery.Fixtures do
|
|||||||
@spec container_fixture(attrs :: map(), User.t()) :: Container.t()
|
@spec container_fixture(attrs :: map(), User.t()) :: Container.t()
|
||||||
def container_fixture(attrs \\ %{}, %User{} = user) do
|
def container_fixture(attrs \\ %{}, %User{} = user) do
|
||||||
attrs
|
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)
|
|> Containers.create_container(user)
|
||||||
|> unwrap_ok_tuple()
|
|> unwrap_ok_tuple()
|
||||||
end
|
end
|
||||||
@ -103,7 +108,40 @@ defmodule Cannery.Fixtures do
|
|||||||
@spec ammo_type_fixture(attrs :: map(), User.t()) :: AmmoType.t()
|
@spec ammo_type_fixture(attrs :: map(), User.t()) :: AmmoType.t()
|
||||||
def ammo_type_fixture(attrs \\ %{}, %User{} = user) do
|
def ammo_type_fixture(attrs \\ %{}, %User{} = user) do
|
||||||
attrs
|
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)
|
|> Ammo.create_ammo_type(user)
|
||||||
|> unwrap_ok_tuple()
|
|> unwrap_ok_tuple()
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user