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.67.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.66.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.65.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.64.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.63.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.62.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.61.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.60.1 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.60.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.59.2 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.59.1 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.59.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.58.3 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.58.2 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.58.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.57.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.56.1 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.56.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.55.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.54.0 spec/lib/pact_broker/verifications/sequence_spec.rb