Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 1bb3354

Browse files
author
Chris Rees
committed
Add tests around the min/max player validation
1 parent bc6932f commit 1bb3354

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/agoneum/games/games_test.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ defmodule Agoneum.GamesTest do
4343
assert {:error, %Ecto.Changeset{}} = Games.create_game(@invalid_attrs)
4444
end
4545

46+
test "create_game/1 fails when min players is greater than max players" do
47+
invalid_attrs = %{description: "some description", min_players: 2, max_players: 1, name: "some name", year: 42}
48+
assert {:error, %Ecto.Changeset{}} = Games.create_game(invalid_attrs)
49+
end
50+
4651
test "update_game/2 with valid data updates the game" do
4752
game = game_fixture()
4853
assert {:ok, game} = Games.update_game(game, @update_attrs)
@@ -61,6 +66,13 @@ defmodule Agoneum.GamesTest do
6166
assert game == Games.get_game!(game.id)
6267
end
6368

69+
test "update_game/1 fails when min players is greater than max players" do
70+
game = game_fixture()
71+
invalid_attrs = %{min_players: 2, max_players: 1}
72+
assert {:error, %Ecto.Changeset{}} = Games.update_game(game, invalid_attrs)
73+
assert game == Games.get_game!(game.id)
74+
end
75+
6476
test "delete_game/1 deletes the game" do
6577
game = game_fixture()
6678
assert {:ok, %Game{}} = Games.delete_game(game)
@@ -71,5 +83,6 @@ defmodule Agoneum.GamesTest do
7183
game = game_fixture()
7284
assert %Ecto.Changeset{} = Games.change_game(game)
7385
end
86+
7487
end
7588
end

0 commit comments

Comments
 (0)