debian-mirror-gitlab/spec/lib/gitlab/database/consistency_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
713 B
Ruby
Raw Normal View History

2021-09-04 01:27:46 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Database::Consistency do
let(:session) do
Gitlab::Database::LoadBalancing::Session.current
end
2021-11-18 22:05:49 +05:30
before do
Gitlab::Database::LoadBalancing::Session.clear_session
end
after do
Gitlab::Database::LoadBalancing::Session.clear_session
end
2021-09-04 01:27:46 +05:30
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