gitlab-org--gitlab-foss/spec/workers/stuck_ci_jobs_worker_spec.rb

39 lines
1.0 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
2015-10-21 09:29:47 +00:00
RSpec.describe StuckCiJobsWorker do
include ExclusiveLeaseHelpers
let(:worker) { described_class.new }
let(:lease_uuid) { SecureRandom.uuid }
describe '#perform' do
subject { worker.perform }
it 'enqueues a Ci::StuckBuilds::DropRunningWorker job' do
expect(Ci::StuckBuilds::DropRunningWorker).to receive(:perform_in).with(20.minutes).exactly(:once)
subject
end
it 'enqueues a Ci::StuckBuilds::DropScheduledWorker job' do
expect(Ci::StuckBuilds::DropScheduledWorker).to receive(:perform_in).with(40.minutes).exactly(:once)
subject
end
it 'executes an instance of Ci::StuckBuilds::DropPendingService' do
expect_to_obtain_exclusive_lease(worker.lease_key, lease_uuid)
expect_next_instance_of(Ci::StuckBuilds::DropPendingService) do |service|
expect(service).to receive(:execute).exactly(:once)
end
expect_to_cancel_exclusive_lease(worker.lease_key, lease_uuid)
2018-09-27 09:17:43 +00:00
subject
2018-09-27 09:17:43 +00:00
end
end
2017-03-01 12:56:54 +00:00
end