summaryrefslogtreecommitdiff
path: root/spec/workers/ci/update_locked_unknown_artifacts_worker_spec.rb
blob: b42d135b1b6b978e5561f4df3104bcd430bcc50a (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
41
42
43
44
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Ci::UpdateLockedUnknownArtifactsWorker do
  let(:worker) { described_class.new }

  describe '#perform' do
    it 'executes an instance of Ci::JobArtifacts::UpdateUnknownLockedStatusService' do
      expect_next_instance_of(Ci::JobArtifacts::UpdateUnknownLockedStatusService) do |instance|
        expect(instance).to receive(:execute).and_call_original
      end

      expect(worker).to receive(:log_extra_metadata_on_done).with(:removed_count, 0)
      expect(worker).to receive(:log_extra_metadata_on_done).with(:locked_count, 0)

      worker.perform
    end

    context 'with the ci_job_artifacts_backlog_work flag shut off' do
      before do
        stub_feature_flags(ci_job_artifacts_backlog_work: false)
      end

      it 'does not instantiate a new Ci::JobArtifacts::UpdateUnknownLockedStatusService' do
        expect(Ci::JobArtifacts::UpdateUnknownLockedStatusService).not_to receive(:new)

        worker.perform
      end

      it 'does not log any artifact counts' do
        expect(worker).not_to receive(:log_extra_metadata_on_done)

        worker.perform
      end

      it 'does not query the database' do
        query_count = ActiveRecord::QueryRecorder.new { worker.perform }.count

        expect(query_count).to eq(0)
      end
    end
  end
end