Skip to content

Commit

Permalink
feat: log tagging to stdout when publishing verification results
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jun 9, 2018
1 parent f689306 commit 2387424
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/pact/provider/verification_results/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def tag_versions
provider_application_version = Pact.configuration.provider.application_version

Pact.configuration.provider.tags.each do | tag |
Pact.configuration.output_stream.puts "INFO: Tagging version #{provider_application_version} of #{provider_name} as #{tag.inspect}"
tag_entity = tag_link.expand(version: provider_application_version, tag: tag).put
unless tag_entity.success?
raise PublicationError.new("Error returned from tagging request #{tag_entity.response.code} #{tag_entity.response.body}")
Expand Down Expand Up @@ -109,6 +110,10 @@ def publish_verification_results
def consumer_name
pact_source.pact_hash['consumer']['name']
end

def provider_name
pact_source.pact_hash['provider']['name']
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/pact/provider/verification_results/publish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module VerificationResults
'consumer' => {
'name' => 'Foo'
},
'provider' => {
'name' => 'Bar'
},
'_links' => {
'pb:publish-verification-results'=> {
'href' => publish_verification_url
Expand Down Expand Up @@ -121,6 +124,11 @@ module VerificationResults
expect(WebMock).to have_requested(:put, 'http://provider/version/1.2.3/tag/foo').with(headers: {'Content-Type' => 'application/json'})
end

it "logs the tagging to stdout" do
expect($stdout).to receive(:puts).with("INFO: Tagging version 1.2.3 of Bar as \"foo\"")
subject
end

context "when there is no pb:publish-verification-results link" do
before do
pact_hash['_links'].delete('pb:publish-verification-results')
Expand Down

0 comments on commit 2387424

Please sign in to comment.