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

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

require 'spec_helper'
require_relative './simple_check_shared'

RSpec.describe Gitlab::HealthChecks::DbCheck do
  include_examples 'simple_check', 'db_ping', 'Db', Gitlab::Database.database_base_models.size

  context 'with multiple databases' do
    subject { described_class.readiness }

    before do
      allow(Gitlab::Database).to receive(:database_base_models)
        .and_return({ main: ApplicationRecord, ci: Ci::ApplicationRecord }.with_indifferent_access)
    end

    it 'checks multiple databases' do
      expect(ApplicationRecord.connection).to receive(:select_value).with('SELECT 1').and_call_original
      expect(Ci::ApplicationRecord.connection).to receive(:select_value).with('SELECT 1').and_call_original
      expect(subject).to have_attributes(success: true)
    end
  end
end