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

index_inconsistencies_metric_spec.rb « instrumentations « metrics « usage « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: afc9d610207b83fc5c6791b2d9bbf46ba63d92a3 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Usage::Metrics::Instrumentations::IndexInconsistenciesMetric, feature_category: :database do
  it_behaves_like 'a correct instrumented metric value', { time_frame: 'all' } do
    let(:expected_value) do
      [
        { inconsistency_type: 'wrong_indexes', object_name: 'index_name_1' },
        { inconsistency_type: 'missing_indexes', object_name: 'index_name_2' },
        { inconsistency_type: 'extra_indexes', object_name: 'index_name_3' }
      ]
    end

    let(:runner) { instance_double(Gitlab::Database::SchemaValidation::Runner, execute: inconsistencies) }
    let(:inconsistency_class) { Gitlab::Database::SchemaValidation::Validators::BaseValidator::Inconsistency }

    let(:inconsistencies) do
      [
        instance_double(inconsistency_class, object_name: 'index_name_1', type: 'wrong_indexes'),
        instance_double(inconsistency_class, object_name: 'index_name_2', type: 'missing_indexes'),
        instance_double(inconsistency_class, object_name: 'index_name_3', type: 'extra_indexes')
      ]
    end

    before do
      allow(Gitlab::Database::SchemaValidation::Runner).to receive(:new).and_return(runner)
    end
  end
end