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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/database/consistency_spec.rb')
-rw-r--r--spec/lib/gitlab/database/consistency_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/consistency_spec.rb b/spec/lib/gitlab/database/consistency_spec.rb
new file mode 100644
index 00000000000..35fa65512ae
--- /dev/null
+++ b/spec/lib/gitlab/database/consistency_spec.rb
@@ -0,0 +1,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