Skip to content

Commit

Permalink
fix(verifications): do not print warning about missing pb:tag-version…
Browse files Browse the repository at this point in the history
… link when there are no tags configured
  • Loading branch information
bethesque committed Oct 31, 2017
1 parent 7e078bd commit ed9468a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/pact/provider/verification_results/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ def initialize pact_source, verification_result

def call
if Pact.configuration.provider.publish_verification_results?
if tag_url('')
tag
else
Pact.configuration.error_stream.puts "WARN: Cannot tag provider version as there is no link named pb:tag-version in the pact JSON."
if Pact.configuration.provider.tags.any?
if tag_url('')
tag_versions
else
Pact.configuration.error_stream.puts "WARN: Cannot tag provider version as there is no link named pb:tag-version in the pact JSON."
end
end

if publication_url
publish
else
Expand All @@ -47,7 +50,7 @@ def tag_url tag
href ? href.gsub('{tag}', tag) : nil
end

def tag
def tag_versions
Pact.configuration.provider.tags.each do | tag |
uri = URI(tag_url(tag))
request = build_request('Put', uri, nil, "Tagging provider version at")
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/pact/provider/verification_results/publish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ module VerificationResults
end
end

context "when there are no tags specified and there is no pb:tag-version link" do
before do
pact_hash['_links'].delete('pb:tag-version')
end
let(:tags) { [] }

it "does not print a warning" do
expect($stderr).to_not receive(:puts).with /WARN: Cannot tag provider version/
subject
end
end

context "when basic auth is configured on the pact URL" do
let(:basic_auth) { true }
it "sets the username and password for the pubication URL" do
Expand Down

0 comments on commit ed9468a

Please sign in to comment.