Sha256: 27637e56ab9e606ca57b384e97a3be83cb28cf8d08f3616828528282c81d6e23

Contents?: true

Size: 1.42 KB

Versions: 75

Compression:

Stored size: 1.42 KB

Contents

require 'pact_broker/verifications/sequence'

module PactBroker
  module Verifications
    describe Sequence do
      describe "#next_val", migration: true do

        before do
          PactBroker::Database.migrate
        end

        context "when there is a row in the verification_sequence_number table" do
          before do
            Sequence.select_all.delete
            Sequence.insert(value: 1)
          end

          it "increments the value and returns it" do
            expect(Sequence.next_val).to eq 2
          end
        end

        context "when there is no row in the verification_sequence_number table and no existing verifications" do
          before do
            Sequence.select_all.delete
          end

          it "inserts and returns the value 1" do
            expect(Sequence.next_val).to eq 1
          end
        end

        context "when there is no row in the verification_sequence_number table and there are existing verifications" do
          before do
            Sequence.select_all.delete
            TestDataBuilder.new.create_pact_with_hierarchy("A", "1", "B")
              .create_verification(provider_version: "2")
          end

          it "inserts a number that is guaranteed to be higher than any of the existing verification numbers from when we tried to do this without a sequence" do
            expect(Sequence.next_val).to eq 101
          end
        end
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
pact_broker-2.38.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.37.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.36.1 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.36.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.35.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.34.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.33.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.32.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.31.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.30.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.29.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.27.6 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.27.5 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.27.4 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.27.3 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.27.2 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.27.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.26.1 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.26.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.25.0 spec/lib/pact_broker/verifications/sequence_spec.rb