After "mix phx.gen.live Biddings Bidding biddings bidding_round:integer amount:integer depot_wish_one:string depot_wish_two:string".

This commit is contained in:
2026-02-11 16:14:19 +01:00
parent 7ad08fa91d
commit 2bec68b9ed
9 changed files with 677 additions and 0 deletions

View File

@ -0,0 +1,97 @@
defmodule BeetRoundServer.BiddingsTest do
use BeetRoundServer.DataCase
alias BeetRoundServer.Biddings
describe "biddings" do
alias BeetRoundServer.Biddings.Bidding
import BeetRoundServer.AccountsFixtures, only: [user_scope_fixture: 0]
import BeetRoundServer.BiddingsFixtures
@invalid_attrs %{amount: nil, bidding_round: nil, depot_wish_one: nil, depot_wish_two: nil}
test "list_biddings/1 returns all scoped biddings" do
scope = user_scope_fixture()
other_scope = user_scope_fixture()
bidding = bidding_fixture(scope)
other_bidding = bidding_fixture(other_scope)
assert Biddings.list_biddings(scope) == [bidding]
assert Biddings.list_biddings(other_scope) == [other_bidding]
end
test "get_bidding!/2 returns the bidding with given id" do
scope = user_scope_fixture()
bidding = bidding_fixture(scope)
other_scope = user_scope_fixture()
assert Biddings.get_bidding!(scope, bidding.id) == bidding
assert_raise Ecto.NoResultsError, fn -> Biddings.get_bidding!(other_scope, bidding.id) end
end
test "create_bidding/2 with valid data creates a bidding" do
valid_attrs = %{amount: 42, bidding_round: 42, depot_wish_one: "some depot_wish_one", depot_wish_two: "some depot_wish_two"}
scope = user_scope_fixture()
assert {:ok, %Bidding{} = bidding} = Biddings.create_bidding(scope, valid_attrs)
assert bidding.amount == 42
assert bidding.bidding_round == 42
assert bidding.depot_wish_one == "some depot_wish_one"
assert bidding.depot_wish_two == "some depot_wish_two"
assert bidding.user_id == scope.user.id
end
test "create_bidding/2 with invalid data returns error changeset" do
scope = user_scope_fixture()
assert {:error, %Ecto.Changeset{}} = Biddings.create_bidding(scope, @invalid_attrs)
end
test "update_bidding/3 with valid data updates the bidding" do
scope = user_scope_fixture()
bidding = bidding_fixture(scope)
update_attrs = %{amount: 43, bidding_round: 43, depot_wish_one: "some updated depot_wish_one", depot_wish_two: "some updated depot_wish_two"}
assert {:ok, %Bidding{} = bidding} = Biddings.update_bidding(scope, bidding, update_attrs)
assert bidding.amount == 43
assert bidding.bidding_round == 43
assert bidding.depot_wish_one == "some updated depot_wish_one"
assert bidding.depot_wish_two == "some updated depot_wish_two"
end
test "update_bidding/3 with invalid scope raises" do
scope = user_scope_fixture()
other_scope = user_scope_fixture()
bidding = bidding_fixture(scope)
assert_raise MatchError, fn ->
Biddings.update_bidding(other_scope, bidding, %{})
end
end
test "update_bidding/3 with invalid data returns error changeset" do
scope = user_scope_fixture()
bidding = bidding_fixture(scope)
assert {:error, %Ecto.Changeset{}} = Biddings.update_bidding(scope, bidding, @invalid_attrs)
assert bidding == Biddings.get_bidding!(scope, bidding.id)
end
test "delete_bidding/2 deletes the bidding" do
scope = user_scope_fixture()
bidding = bidding_fixture(scope)
assert {:ok, %Bidding{}} = Biddings.delete_bidding(scope, bidding)
assert_raise Ecto.NoResultsError, fn -> Biddings.get_bidding!(scope, bidding.id) end
end
test "delete_bidding/2 with invalid scope raises" do
scope = user_scope_fixture()
other_scope = user_scope_fixture()
bidding = bidding_fixture(scope)
assert_raise MatchError, fn -> Biddings.delete_bidding(other_scope, bidding) end
end
test "change_bidding/2 returns a bidding changeset" do
scope = user_scope_fixture()
bidding = bidding_fixture(scope)
assert %Ecto.Changeset{} = Biddings.change_bidding(scope, bidding)
end
end
end