Skip to content

Commit 3c209a4

Browse files
committed
fix: raise PactBroker::Error when either pacticipant is not found in the business layer while attempting to delete an integration
1 parent 690e6cf commit 3c209a4

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

lib/pact_broker/integrations/service.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def self.find_all
3131
end
3232

3333
def self.delete(consumer_name, provider_name)
34-
consumer = pacticipant_service.find_pacticipant_by_name(consumer_name)
35-
provider = pacticipant_service.find_pacticipant_by_name(provider_name)
34+
consumer = pacticipant_service.find_pacticipant_by_name!(consumer_name)
35+
provider = pacticipant_service.find_pacticipant_by_name!(provider_name)
3636
# this takes care of the triggered webhooks and webhook executions
3737
pact_service.delete_all_pact_publications_between(consumer_name, and: provider_name)
3838
verification_service.delete_all_verifications_between(consumer_name, and: provider_name)

lib/pact_broker/pacts/repository.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def find_all_pact_versions_between consumer_name, options
107107
end
108108

109109
def delete_all_pact_publications_between consumer_name, options
110-
consumer = pacticipant_repository.find_by_name(consumer_name)
111-
provider = pacticipant_repository.find_by_name(options.fetch(:and))
110+
consumer = pacticipant_repository.find_by_name!(consumer_name)
111+
provider = pacticipant_repository.find_by_name!(options.fetch(:and))
112112
query = PactPublication.where(consumer: consumer, provider: provider)
113113
query = query.tag(options[:tag]) if options[:tag]
114114

lib/pact_broker/verifications/repository.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ def delete_by_provider_version_id version_id
136136
end
137137

138138
def delete_all_verifications_between(consumer_name, options)
139-
consumer = pacticipant_repository.find_by_name(consumer_name)
140-
provider = pacticipant_repository.find_by_name(options.fetch(:and))
139+
consumer = pacticipant_repository.find_by_name!(consumer_name)
140+
provider = pacticipant_repository.find_by_name!(options.fetch(:and))
141141
PactBroker::Domain::Verification.where(provider: provider, consumer: consumer).delete
142142
end
143143

spec/features/delete_integration_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe "Deleting pact versions" do
1+
describe "Deleting an integration" do
22

33
let(:path) { "/integrations/provider/Bar/consumer/Foo" }
44

@@ -19,7 +19,7 @@
1919
end
2020
end
2121

22-
context "when the pact does not exist" do
22+
context "when the integration does not exist" do
2323
it "returns a 404 Not Found" do
2424
expect(subject.status).to be 404
2525
end

spec/lib/pact_broker/integrations/service_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ module Integrations
248248
Service.delete("Foo", "Foo")
249249
end
250250
end
251+
252+
context "when the pacticipants are not found for some bizarre reason (I can't see how this can happen, but it has)" do
253+
it "raises an error" do
254+
expect { Service.delete("Foo", "Bar") }.to raise_error(PactBroker::Error, /found/)
255+
end
256+
end
251257
end
252258

253259
describe "delete_all" do

0 commit comments

Comments
 (0)