diff options
Diffstat (limited to 'spec/workers/clusters/agents/delete_expired_events_worker_spec.rb')
-rw-r--r-- | spec/workers/clusters/agents/delete_expired_events_worker_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/workers/clusters/agents/delete_expired_events_worker_spec.rb b/spec/workers/clusters/agents/delete_expired_events_worker_spec.rb new file mode 100644 index 00000000000..1a5ca744091 --- /dev/null +++ b/spec/workers/clusters/agents/delete_expired_events_worker_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Clusters::Agents::DeleteExpiredEventsWorker 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 |