Sha256: 317fcd7ce2e1efae52c3ad6c6fa372b8912e1bd5cce452a77ca6873f500ca02b

Contents?: true

Size: 1.09 KB

Versions: 47

Compression:

Stored size: 1.09 KB

Contents

require 'sucker_punch'
require 'faraday'
require 'pact_broker/logging'


# Publishes verification results, as if they were triggered by a CI job
module PactBroker
  class VerificationJob
    include SuckerPunch::Job
    include PactBroker::Logging

    def perform data
      pact_url = data.fetch(:pactUrl)
      pact = Faraday.get(pact_url, nil, { 'Accept' => 'application/hal+json'}).body
      pact_hash = JSON.parse(pact)

      headers = {
        'Content-Type' => 'application/json',
        'Accept' => 'application/hal+json'
      }

      provider_version = "1.2.#{(rand * 1000).to_i}"
      provider_url = pact_hash['_links']['pb:provider']['href']
      Faraday.put("#{provider_url}/versions/#{provider_version}/tags/dev", nil, headers)

      verification_url = pact_hash['_links']['pb:publish-verification-results']['href']
      body = {
        success: true,
        providerApplicationVersion: provider_version
      }

      Faraday.post(verification_url, body.to_json, headers)
      sleep 3
      Faraday.put("#{provider_url}/versions/#{provider_version}/tags/prod", nil, headers)
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
pact_broker-2.79.1 spec/support/verification_job.rb
pact_broker-2.79.0 spec/support/verification_job.rb
pact_broker-2.78.1 spec/support/verification_job.rb
pact_broker-2.78.0 spec/support/verification_job.rb
pact_broker-2.77.0 spec/support/verification_job.rb
pact_broker-2.76.2 spec/support/verification_job.rb
pact_broker-2.76.1 spec/support/verification_job.rb
pact_broker-2.76.0 spec/support/verification_job.rb
pact_broker-2.75.0 spec/support/verification_job.rb
pact_broker-2.74.1 spec/support/verification_job.rb
pact_broker-2.74.0 spec/support/verification_job.rb
pact_broker-2.73.0 spec/support/verification_job.rb
pact_broker-2.72.0 spec/support/verification_job.rb
pact_broker-2.71.0 spec/support/verification_job.rb
pact_broker-2.70.0 spec/support/verification_job.rb
pact_broker-2.69.0 spec/support/verification_job.rb
pact_broker-2.68.1 spec/support/verification_job.rb
pact_broker-2.68.0 spec/support/verification_job.rb
pact_broker-2.67.0 spec/support/verification_job.rb
pact_broker-2.66.0 spec/support/verification_job.rb