2019-03-30 03:15:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-14 06:53:51 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe BuildFinishedWorker do
|
2020-06-02 17:08:00 -04:00
|
|
|
subject { described_class.new.perform(build.id) }
|
|
|
|
|
2016-10-14 06:53:51 -04:00
|
|
|
describe '#perform' do
|
2020-06-02 17:08:00 -04:00
|
|
|
let(:build) { create(:ci_build, :success, pipeline: create(:ci_pipeline)) }
|
|
|
|
|
2016-10-14 06:53:51 -04:00
|
|
|
context 'when build exists' do
|
2017-08-23 05:46:10 -04:00
|
|
|
let!(:build) { create(:ci_build) }
|
2016-10-14 06:53:51 -04:00
|
|
|
|
|
|
|
it 'calculates coverage and calls hooks' do
|
2018-02-05 11:52:46 -05:00
|
|
|
expect(BuildTraceSectionsWorker)
|
2016-10-14 06:53:51 -04:00
|
|
|
.to receive(:new).ordered.and_call_original
|
2018-02-05 11:52:46 -05:00
|
|
|
expect(BuildCoverageWorker)
|
2016-10-14 06:53:51 -04:00
|
|
|
.to receive(:new).ordered.and_call_original
|
|
|
|
|
2018-02-05 11:52:46 -05:00
|
|
|
expect_any_instance_of(BuildTraceSectionsWorker).to receive(:perform)
|
|
|
|
expect_any_instance_of(BuildCoverageWorker).to receive(:perform)
|
|
|
|
expect(BuildHooksWorker).to receive(:perform_async)
|
2018-03-06 07:40:50 -05:00
|
|
|
expect(ArchiveTraceWorker).to receive(:perform_async)
|
2019-05-20 20:31:03 -04:00
|
|
|
expect(ExpirePipelineCacheWorker).to receive(:perform_async)
|
2020-06-02 17:08:00 -04:00
|
|
|
expect(ChatNotificationWorker).not_to receive(:perform_async)
|
|
|
|
expect(Ci::BuildReportResultWorker).not_to receive(:perform)
|
2016-10-14 06:53:51 -04:00
|
|
|
|
2020-06-02 17:08:00 -04:00
|
|
|
subject
|
2016-10-14 06:53:51 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when build does not exist' do
|
|
|
|
it 'does not raise exception' do
|
|
|
|
expect { described_class.new.perform(123) }
|
|
|
|
.not_to raise_error
|
|
|
|
end
|
|
|
|
end
|
2019-02-20 16:29:48 -05:00
|
|
|
|
2020-06-02 17:08:00 -04:00
|
|
|
context 'when build has a chat' do
|
|
|
|
let(:build) { create(:ci_build, :success, pipeline: create(:ci_pipeline, source: :chat)) }
|
2019-02-20 16:29:48 -05:00
|
|
|
|
2020-06-02 17:08:00 -04:00
|
|
|
it 'schedules a ChatNotification job' do
|
|
|
|
expect(ChatNotificationWorker).to receive(:perform_async).with(build.id)
|
2019-02-20 16:29:48 -05:00
|
|
|
|
2020-06-02 17:08:00 -04:00
|
|
|
subject
|
|
|
|
end
|
2019-02-20 16:29:48 -05:00
|
|
|
end
|
|
|
|
|
2020-06-02 17:08:00 -04:00
|
|
|
context 'when build has a test report' do
|
|
|
|
let(:build) { create(:ci_build, :test_reports) }
|
2019-02-20 16:29:48 -05:00
|
|
|
|
2020-06-02 17:08:00 -04:00
|
|
|
it 'schedules a BuildReportResult job' do
|
|
|
|
expect_next_instance_of(Ci::BuildReportResultWorker) do |worker|
|
|
|
|
expect(worker).to receive(:perform).with(build.id)
|
|
|
|
end
|
2019-02-20 16:29:48 -05:00
|
|
|
|
2020-06-02 17:08:00 -04:00
|
|
|
subject
|
|
|
|
end
|
2019-02-20 16:29:48 -05:00
|
|
|
end
|
2016-10-14 06:53:51 -04:00
|
|
|
end
|
|
|
|
end
|