Sha256: 38c545820d9d686a83a62400817382d1930a6045f0991b24baca78cda83c8a81

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require "pact_broker/client/can_i_deploy"

module PactBroker
  module Client
    class VerificationRequired < PactBroker::Client::CanIDeploy
      def call
        create_result(fetch_matrix_with_retries)
      rescue StandardError => e
        message = "Error determining if a verification already existed (#{e.message}) - verification should run just in case"
        if options[:verbose]
          message = "#{message}\n#{e.class} - #{e.backtrace.join("\n")}"
        end
        Result.new(true, message)
      end

      private

      def create_result(matrix)
        matrix_and_notices = format_matrix(matrix) + "\n\n" + remove_warnings(Term::ANSIColor.uncolor(notice_or_reason(matrix, :white)))
        if matrix.any_unknown?
          Result.new(true, matrix_and_notices + "\n\nVerification is required.")
        else
          Result.new(false, matrix_and_notices + "\n\nNo verification is required.")
        end
      end

      def remove_warnings(lines)
        lines.split("\n").select{ | line | !line.include?("WARN:") }.join("\n")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact_broker-client-1.47.0 lib/pact_broker/client/verification_required.rb