diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-09 15:08:32 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-09 15:08:32 +0000 |
commit | e9de69b545c25c9cb7fd410f9bf8ba34c6bb727b (patch) | |
tree | a59ae937a12f9e03e7c4269af4a3a0fcb1e540b2 /spec/lib/gitlab/database/indexing_exclusive_lease_guard_spec.rb | |
parent | 1935f3e81b99c00697bf0b4d6a44d64068b34745 (diff) | |
download | gitlab-ce-e9de69b545c25c9cb7fd410f9bf8ba34c6bb727b.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/database/indexing_exclusive_lease_guard_spec.rb')
-rw-r--r-- | spec/lib/gitlab/database/indexing_exclusive_lease_guard_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/indexing_exclusive_lease_guard_spec.rb b/spec/lib/gitlab/database/indexing_exclusive_lease_guard_spec.rb new file mode 100644 index 00000000000..ddc9cdee92f --- /dev/null +++ b/spec/lib/gitlab/database/indexing_exclusive_lease_guard_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Database::IndexingExclusiveLeaseGuard, feature_category: :database do + let(:helper_class) do + Class.new do + include Gitlab::Database::IndexingExclusiveLeaseGuard + + attr_reader :connection + + def initialize(connection) + @connection = connection + end + end + end + + describe '#lease_key' do + let(:helper) { helper_class.new(connection) } + let(:lease_key) { "gitlab/database/indexing/actions/#{database_name}" } + + context 'with CI database connection' do + let(:connection) { Ci::ApplicationRecord.connection } + let(:database_name) { Gitlab::Database::CI_DATABASE_NAME } + + before do + skip_if_multiple_databases_not_setup + end + + it { expect(helper.lease_key).to eq(lease_key) } + end + + context 'with MAIN database connection' do + let(:connection) { ApplicationRecord.connection } + let(:database_name) { Gitlab::Database::MAIN_DATABASE_NAME } + + it { expect(helper.lease_key).to eq(lease_key) } + end + end +end |