blob: 60ccf5ec685d90dc18e6ce250bf0bafe54dee461 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Database::AsyncDdlExclusiveLeaseGuard, feature_category: :database do
let(:helper_class) do
Class.new do
include Gitlab::Database::AsyncDdlExclusiveLeaseGuard
attr_reader :connection_db_config
def initialize(connection_db_config)
@connection_db_config = connection_db_config
end
end
end
describe '#lease_key' do
let(:helper) { helper_class.new(connection_db_config) }
let(:lease_key) { "gitlab/database/asyncddl/actions/#{database_name}" }
context 'with CI database connection' do
let(:connection_db_config) { Ci::ApplicationRecord.connection_db_config }
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_db_config) { ApplicationRecord.connection_db_config }
let(:database_name) { Gitlab::Database::MAIN_DATABASE_NAME }
it { expect(helper.lease_key).to eq(lease_key) }
end
end
end
|