diff --git a/lib/pact/provider/verification_results/publish.rb b/lib/pact/provider/verification_results/publish.rb index 12f351c6..9eb3a0a2 100644 --- a/lib/pact/provider/verification_results/publish.rb +++ b/lib/pact/provider/verification_results/publish.rb @@ -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 @@ -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") diff --git a/spec/lib/pact/provider/verification_results/publish_spec.rb b/spec/lib/pact/provider/verification_results/publish_spec.rb index 0950fa78..cd7988b1 100644 --- a/spec/lib/pact/provider/verification_results/publish_spec.rb +++ b/spec/lib/pact/provider/verification_results/publish_spec.rb @@ -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