Welcome to mirror list, hosted at ThFree Co, Russian Federation.

consistency_spec.rb « database « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 35fa65512aefdc6662fb82bc1422541067bdaaac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Database::Consistency do
  let(:session) do
    Gitlab::Database::LoadBalancing::Session.current
  end

  describe '.with_read_consistency' do
    it 'sticks to primary database' do
      expect(session).not_to be_using_primary

      block = -> (&control) do
        described_class.with_read_consistency do
          expect(session).to be_using_primary

          control.call
        end
      end

      expect { |probe| block.call(&probe) }.to yield_control
    end
  end
end