diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-05 03:12:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-05 03:12:25 +0300 |
commit | 33a1d1835f5fc146acf0cdda402b5a327ae0d52f (patch) | |
tree | 670a2d95c957a475866507f87358c55f20359672 /spec/workers/ci | |
parent | 8c6c2136e8cf8d0a857e587c36448db86965d146 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/ci')
-rw-r--r-- | spec/workers/ci/stuck_builds/drop_scheduled_worker_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/workers/ci/stuck_builds/drop_scheduled_worker_spec.rb b/spec/workers/ci/stuck_builds/drop_scheduled_worker_spec.rb new file mode 100644 index 00000000000..57be799d890 --- /dev/null +++ b/spec/workers/ci/stuck_builds/drop_scheduled_worker_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::StuckBuilds::DropScheduledWorker do + include ExclusiveLeaseHelpers + + let(:worker) { described_class.new } + let(:lease_uuid) { SecureRandom.uuid } + + describe '#perform' do + subject { worker.perform } + + it_behaves_like 'an idempotent worker' + + it 'executes an instance of Ci::StuckBuilds::DropScheduledService with an exclusive lease' do + expect_to_obtain_exclusive_lease(worker.lease_key, lease_uuid) + + expect_next_instance_of(Ci::StuckBuilds::DropScheduledService) do |service| + expect(service).to receive(:execute).exactly(:once) + end + + expect_to_cancel_exclusive_lease(worker.lease_key, lease_uuid) + + subject + end + end +end |