Skip to content

Commit f8f2b6a

Browse files
committed
test: assert persisted name after replace_all upsert
1 parent bd7cd99 commit f8f2b6a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

test/ecto_integration_test.exs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,14 +947,16 @@ defmodule Ecto.Integration.EctoLibSqlTest do
947947
conflict_target: :email
948948
)
949949

950-
{:ok, updated} =
950+
{:ok, _updated} =
951951
TestRepo.insert(%User{name: "Alice Updated", email: "alice@example.com"},
952952
on_conflict: :replace_all,
953953
conflict_target: :email
954954
)
955955

956-
# The email is the conflict target - name should reflect the upserted value.
957-
assert updated.email == "alice@example.com"
956+
# Fetch from the DB to confirm the change was actually persisted, not just
957+
# reflected in the returned struct.
958+
reloaded = TestRepo.get_by!(User, email: "alice@example.com")
959+
assert reloaded.name == "Alice Updated"
958960
assert TestRepo.aggregate(User, :count, :id) == 1
959961
end
960962

0 commit comments

Comments
 (0)