File: partitioning_worker_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (50 lines) | stat: -rw-r--r-- 1,493 bytes parent folder | download
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
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Ci::PartitioningWorker, feature_category: :ci_scaling do
  describe '#perform' do
    subject(:perform) { described_class.new.perform }

    let(:default_service) { instance_double(Ci::Partitions::SetupDefaultService) }

    it 'calls setup default service' do
      expect(Ci::Partitions::SetupDefaultService).to receive(:new).and_return(default_service)
      expect(default_service).to receive(:execute)

      perform
    end

    context 'when current partition does not exist' do
      before do
        allow(Ci::Partition).to receive(:current).and_return(nil)
      end

      it 'does not call services', :aggregate_failures do
        expect(Ci::Partitions::CreateService).not_to receive(:new)
        expect(Ci::Partitions::SyncService).not_to receive(:new)

        perform
      end
    end

    context 'when current partition exists' do
      let(:create_service) { instance_double(Ci::Partitions::CreateService) }
      let(:sync_service) { instance_double(Ci::Partitions::SyncService) }

      it 'calls create service' do
        expect(Ci::Partitions::CreateService).to receive(:new).and_return(create_service)
        expect(create_service).to receive(:execute)

        perform
      end

      it 'calls sync service' do
        expect(Ci::Partitions::SyncService).to receive(:new).and_return(sync_service)
        expect(sync_service).to receive(:execute)

        perform
      end
    end
  end
end