Commit 69df47c7 authored by Shinya Maeda's avatar Shinya Maeda

Improve spec

parent e8e8ae4d
......@@ -6,28 +6,31 @@ describe StuckCiJobsWorker do
let(:worker) { described_class.new }
let(:exclusive_lease_uuid) { SecureRandom.uuid }
subject do
job.reload
job.status
end
before do
job.update!(status: status, updated_at: updated_at)
allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain).and_return(exclusive_lease_uuid)
end
shared_examples 'job is dropped' do
it 'changes status' do
before do
worker.perform
is_expected.to eq('failed')
job.reload
end
it "changes status" do
expect(job).to be_failed
expect(job).to be_stuck_or_timeout_failure
end
end
shared_examples 'job is unchanged' do
it "doesn't change status" do
before do
worker.perform
is_expected.to eq(status)
job.reload
end
it "doesn't change status" do
expect(job.status).to eq(status)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment