2021-03-11 19:13:27 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe ::Ci::PipelineArtifacts::CreateQualityReportWorker do
|
|
|
|
describe '#perform' do
|
|
|
|
subject { described_class.new.perform(pipeline_id) }
|
|
|
|
|
|
|
|
context 'when pipeline exists' do
|
|
|
|
let(:pipeline) { create(:ci_pipeline, :with_codequality_reports) }
|
|
|
|
let(:pipeline_id) { pipeline.id }
|
|
|
|
|
|
|
|
it 'calls pipeline codequality report service' do
|
|
|
|
expect_next_instance_of(::Ci::PipelineArtifacts::CreateCodeQualityMrDiffReportService) do |quality_report_service|
|
|
|
|
expect(quality_report_service).to receive(:execute)
|
|
|
|
end
|
|
|
|
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'an idempotent worker' do
|
|
|
|
let(:job_args) { pipeline_id }
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it 'does not create another pipeline artifact if already has one' do
|
|
|
|
expect { subject }.not_to change { pipeline.pipeline_artifacts.count }
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipeline does not exist' do
|
|
|
|
let(:pipeline_id) { non_existing_record_id }
|
|
|
|
|
|
|
|
it 'does not call pipeline codequality report service' do
|
|
|
|
expect(Ci::PipelineArtifacts::CreateCodeQualityMrDiffReportService).not_to receive(:execute)
|
|
|
|
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|