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

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

require 'spec_helper'

RSpec.describe DependencyProxy::CleanupDependencyProxyWorker do
  describe '#perform' do
    subject { described_class.new.perform }

    context 'when there are records to be deleted' do
      it_behaves_like 'an idempotent worker' do
        it 'queues the cleanup jobs', :aggregate_failures do
          create(:dependency_proxy_blob, :pending_destruction)
          create(:dependency_proxy_manifest, :pending_destruction)

          expect(DependencyProxy::CleanupBlobWorker).to receive(:perform_with_capacity).twice
          expect(DependencyProxy::CleanupManifestWorker).to receive(:perform_with_capacity).twice

          subject
        end
      end
    end

    context 'when there are not records to be deleted' do
      it_behaves_like 'an idempotent worker' do
        it 'does not queue the cleanup jobs', :aggregate_failures do
          expect(DependencyProxy::CleanupBlobWorker).not_to receive(:perform_with_capacity)
          expect(DependencyProxy::CleanupManifestWorker).not_to receive(:perform_with_capacity)

          subject
        end
      end
    end
  end
end