Skip to content

Commit

Permalink
fix: handle case in no_pacts_found - undefined method empty? for nil
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Aug 6, 2024
1 parent f0f142e commit 0145d2d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/pact/pact_broker/fetch_pact_uris_for_verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def log_message

def handling_no_pacts_found
pacts_found = yield
if pacts_found.empty? && options[:fail_if_no_pacts_found] != false
if pacts_found.blank? && options[:fail_if_no_pacts_found] != false
raise "No pacts found to verify"
else
pacts_found
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module PactBroker
let(:consumer_version_selectors) { [{ tag: "cmaster", latest: true, fallbackTag: 'blah' }] }
let(:provider_version_branch) { "pbranch" }
let(:provider_version_tags) { ["pmaster"] }

subject { FetchPactURIsForVerification.call(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options)}

context "when there is an error retrieving the index resource" do
Expand Down Expand Up @@ -62,7 +62,7 @@ module PactBroker

it "calls the old fetch pacts code" do
expect(FetchPacts).to receive(:call).with(provider, [{ name: "cmaster", all: false, fallback: "blah" }], broker_base_url, http_client_options)
subject
expect { subject }.to raise_error( "No pacts found to verify" )
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module Configuration

let(:fetch_pacts) { double('FetchPacts') }
let(:basic_auth_opts) { basic_auth_options.merge(verbose: true) }
let(:options) { { include_pending_status: true, include_wip_pacts_since: "2020-01-01" }}
let(:options) { { fail_if_no_pacts_found: true, include_pending_status: true, include_wip_pacts_since: "2020-01-01" }}
let(:consumer_version_selectors) { [ { tag: 'master', latest: true }] }

it "creates a instance of Pact::PactBroker::FetchPactURIsForVerification" do
Expand Down Expand Up @@ -70,6 +70,7 @@ module Configuration
anything,
anything,
{
fail_if_no_pacts_found: true,
include_pending_status: true,
include_wip_pacts_since: since.xmlschema
}
Expand Down

0 comments on commit 0145d2d

Please sign in to comment.