summaryrefslogtreecommitdiff
path: root/spec/workers/object_pool/destroy_worker_spec.rb
blob: ef74f0ba87c5f7ec3e26fc80410e6a2e54fc2a49 (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
# frozen_string_literal: true

describe ObjectPool::DestroyWorker do
  describe '#perform' do
    context 'when no pool is in the database' do
      it "doesn't raise an error" do
        expect do
          described_class.new.perform(987654321)
        end.not_to raise_error
      end
    end

    context 'when a pool is present' do
      let(:pool) { create(:pool_repository, :obsolete) }

      subject { described_class.new }

      it 'requests Gitaly to remove the object pool' do
        expect(Gitlab::GitalyClient).to receive(:call).with(pool.shard_name, :object_pool_service, :delete_object_pool, Object)

        subject.perform(pool.id)
      end

      it 'destroys the pool' do
        subject.perform(pool.id)

        expect(PoolRepository.find_by_id(pool.id)).to be_nil
      end
    end
  end
end