summaryrefslogtreecommitdiff
path: root/spec/workers/ci/pipeline_artifacts/coverage_report_worker_spec.rb
blob: 000eda055af2f6e65f443d77c8174e33611543b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ::Ci::PipelineArtifacts::CoverageReportWorker do
  describe '#perform' do
    subject { described_class.new.perform(pipeline_id) }

    context 'when pipeline exists' do
      let(:pipeline) { create(:ci_pipeline) }
      let(:pipeline_id) { pipeline.id }

      it 'calls pipeline report result service' do
        expect_next_instance_of(::Ci::PipelineArtifacts::CoverageReportService) do |create_artifact_service|
          expect(create_artifact_service).to receive(:execute)
        end

        subject
      end
    end

    context 'when pipeline does not exist' do
      let(:pipeline_id) { non_existing_record_id }

      it 'does not call pipeline create artifact service' do
        expect(Ci::PipelineArtifacts::CoverageReportService).not_to receive(:execute)

        subject
      end
    end
  end
end