From bfe6362efdde86dca0690df9b7342bae6420f3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pacana?= Date: Mon, 27 Apr 2026 11:09:23 +0200 Subject: [PATCH] Cover Event#id uniqueness on append - Primary key on events.id enforces uniqueness at the database level, but no integration test exercised the constraint through the adapters. - Add a per-adapter test asserting PG::UniqueViolation propagates on duplicate id append and the store retains only the original event. --- test/test_integration.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/test_integration.rb b/test/test_integration.rb index 8554137..621b665 100644 --- a/test/test_integration.rb +++ b/test/test_integration.rb @@ -88,6 +88,21 @@ module En57 end end + define_method "test_#{name}_append_with_duplicate_id_raises_unique_violation" do + with_event_store(factory) do |event_store| + existing_event = Event.new(id: ids[0], type: "OrderPlaced") + event_store.append([existing_event]) + + assert_raises(PG::UniqueViolation) do + event_store.append( + [Event.new(id: ids[0], type: "ShipmentScheduled")], + ) + end + + assert_equal([existing_event], event_store.read.each.to_a) + end + end + define_method "test_#{name}_tags_round_trip" do with_event_store(factory) do |event_store| event = -- 2.51.2