Sha256: f682f6ed443d6f65a3f3ee4d25822b2575d4a9c806bc578f3b8f2f3e313d0101

Contents?: true

Size: 1.91 KB

Versions: 17

Compression:

Stored size: 1.91 KB

Contents

require 'pact_broker/matrix/repository'

module PactBroker
  module Matrix
    describe Repository do
      let(:td) { TestDataBuilder.new}

      def build_selectors(hash)
        hash.collect do | key, value |
          { pacticipant_name: key, pacticipant_version_number: value }
        end
      end

      def shorten_row row
        "#{row[:consumer_name]}#{row[:consumer_version_number]} #{row[:provider_name]}#{row[:provider_version_number] || '?'} n#{row[:verification_number] || '?'}"
      end

      def shorten_rows rows
        rows.collect{ |r| shorten_row(r) }
      end

      describe "find when deploying a provider to prod for the first time and the consumer has not been deployed yet" do
        before do
          td.create_pact_with_hierarchy("Foo", "1", "Bar")
            .create_verification(provider_version: "2")
        end

        let(:selectors) { [ { pacticipant_name: "Bar", pacticipant_version_number: "2" } ] }
        let(:options) { { latest: true, tag: "prod"} }

        subject { shorten_rows(rows) }
        let(:rows) { Repository.new.find(selectors, options) }

        it "returns an empty array" do
          expect(rows).to eq []
        end
      end

      describe "find when deploying a consumer to prod for the first time and the provider has not been deployed yet" do
        before do
          td.create_pact_with_hierarchy("Foo", "1", "Bar")
            .create_verification(provider_version: "2")
        end

        let(:selectors) { [ { pacticipant_name: "Foo", pacticipant_version_number: "1" } ] }
        let(:options) { { latest: true, tag: "prod"} }

        subject { shorten_rows(rows) }
        let(:results) { Repository.new.find(selectors, options) }

        it "returns an empty array" do
          expect(results).to eq []
          expect(results.resolved_selectors.find{ |s | s[:pacticipant_name] == "Bar"}[:pacticipant_version_id]).to eq -1
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pact_broker-2.43.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.42.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.41.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.40.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.39.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.38.1 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.38.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.37.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.36.1 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.36.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.35.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.34.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.33.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.32.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.31.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.30.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb
pact_broker-2.29.0 spec/lib/pact_broker/matrix/repository_dependency_spec.rb