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

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

require 'spec_helper'

RSpec.describe Gitlab::Database::Partitioning do
  describe '.sync_partitions' do
    let(:partition_manager_class) { described_class::MultiDatabasePartitionManager }
    let(:partition_manager) { double('partition manager') }

    context 'when no partitioned models are given' do
      it 'calls the partition manager with the registered models' do
        expect(partition_manager_class).to receive(:new)
          .with(described_class.registered_models)
          .and_return(partition_manager)

        expect(partition_manager).to receive(:sync_partitions)

        described_class.sync_partitions
      end
    end

    context 'when partitioned models are given' do
      it 'calls the partition manager with the given models' do
        models = ['my special model']

        expect(partition_manager_class).to receive(:new)
          .with(models)
          .and_return(partition_manager)

        expect(partition_manager).to receive(:sync_partitions)

        described_class.sync_partitions(models)
      end
    end
  end
end