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.53.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.52.2 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.52.1 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.52.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.51.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.50.1 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.50.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.49.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.48.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.47.1 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.47.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.46.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.45.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.44.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.43.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.42.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.41.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.40.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.39.0 spec/lib/pact_broker/verifications/sequence_spec.rb
pact_broker-2.38.1 spec/lib/pact_broker/verifications/sequence_spec.rb