Skip to content

Commit f31e8df

Browse files
committed
fix: handle deleting integration when consumer and provider are the same pacticipant
1 parent 07652b5 commit f31e8df

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/pact_broker/integrations/service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def self.delete(consumer_name, provider_name)
2020
version_repository.delete_orphan_versions(consumer, provider)
2121

2222
pacticipant_service.delete_if_orphan(consumer)
23-
pacticipant_service.delete_if_orphan(provider)
23+
pacticipant_service.delete_if_orphan(provider) unless consumer == provider
2424
end
2525
end
2626
end

spec/lib/pact_broker/integrations/service_spec.rb

+13
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ module Integrations
208208
expect { subject }.to change { PactBroker::Domain::Version.count }
209209
end
210210
end
211+
212+
context "when a pacticipant has a pact with itself... I wouldn't have believed it unless I'd seen it..." do
213+
before do
214+
td.create_consumer("Foo")
215+
.use_provider("Foo")
216+
.create_consumer_version("1")
217+
.create_pact
218+
end
219+
220+
it "doesn't blow up" do
221+
Service.delete("Foo", "Foo")
222+
end
223+
end
211224
end
212225
end
213226
end

0 commit comments

Comments
 (0)