Sha256: 751687d6c71ada6e013658eb896bbe77b74f39e025e650f697920a1f38752837

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

# All of these pacts have the same underlying pact_version_sha (content)
# No point verifying them multiple times, so squash all the relevant info into one
# "verifiable pact"

module PactBroker
  module Pacts
    module SquashPactsForVerification
      def self.call(provider_version_tags, selected_pact, include_pending_status = false)
        domain_pact = selected_pact.pact

        if include_pending_status
          pending_provider_tags = []
          non_pending_provider_tags = []
          pending = nil
          if provider_version_tags.any?
            pending_provider_tags = domain_pact.select_pending_provider_version_tags(provider_version_tags)
            pending = pending_provider_tags.any?
          else
            pending = domain_pact.pending?
          end
          non_pending_provider_tags = provider_version_tags - pending_provider_tags
          VerifiablePact.new(
            domain_pact,
            pending,
            pending_provider_tags,
            non_pending_provider_tags,
            selected_pact.tag_names_for_selectors_for_latest_pacts,
            selected_pact.overall_latest?
          )
        else
          VerifiablePact.new(
            domain_pact,
            nil,
            [],
            [],
            selected_pact.tag_names_for_selectors_for_latest_pacts,
            selected_pact.overall_latest?
          )
        end
      end

      def squash_pacts_for_verification(*args)
        SquashPactsForVerification.call(*args)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact_broker-2.47.1 lib/pact_broker/pacts/squash_pacts_for_verification.rb
pact_broker-2.47.0 lib/pact_broker/pacts/squash_pacts_for_verification.rb