File: compare_reports_base_service_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (48 lines) | stat: -rw-r--r-- 1,287 bytes parent folder | download
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Ci::CompareReportsBaseService, feature_category: :continuous_integration do
  let(:service) { described_class.new(project) }
  let(:project) { create(:project, :repository) }

  let!(:base_pipeline) { nil }
  let!(:head_pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
  let!(:key) { service.send(:key, base_pipeline, head_pipeline) }

  describe '#latest?' do
    subject { service.latest?(base_pipeline, head_pipeline, data) }

    context 'when cache key is latest' do
      let(:data) { { key: key } }

      it { is_expected.to be_truthy }
    end

    context 'when cache key is outdated' do
      before do
        head_pipeline.update_column(:updated_at, 10.minutes.ago)
      end

      let(:data) { { key: key } }

      it { is_expected.to be_falsy }
    end

    context 'when cache key is empty' do
      let(:data) { { key: nil } }

      it { is_expected.to be_falsy }
    end
  end

  describe '#execute' do
    context 'when base_pipeline is running' do
      let!(:base_pipeline) { create(:ci_pipeline, :running, project: project) }

      subject { service.execute(base_pipeline, head_pipeline) }

      it { is_expected.to eq(status: :parsing, key: key) }
    end
  end
end