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

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

require 'spec_helper'

RSpec.describe Clusters::Agents::DeleteExpiredEventsWorker, feature_category: :kubernetes_management do
  let(:agent) { create(:cluster_agent) }

  describe '#perform' do
    let(:agent_id) { agent.id }
    let(:deletion_service) { double(execute: true) }

    subject { described_class.new.perform(agent_id) }

    it 'calls the deletion service' do
      expect(deletion_service).to receive(:execute).once
      expect(Clusters::Agents::DeleteExpiredEventsService).to receive(:new)
        .with(agent).and_return(deletion_service)

      subject
    end

    context 'agent no longer exists' do
      let(:agent_id) { -1 }

      it 'completes without raising an error' do
        expect { subject }.not_to raise_error
      end
    end
  end
end