summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/reports/reports_comparer_spec.rb
blob: 1e5e476658368b93f19f20f99d6a1946e78eaa32 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Ci::Reports::ReportsComparer do
  let(:comparer) { described_class.new(base_report, head_report) }
  let(:base_report) { Gitlab::Ci::Reports::CodequalityReports.new }
  let(:head_report) { Gitlab::Ci::Reports::CodequalityReports.new }

  describe '#initialize' do
    context 'sets getter for the report comparer' do
      it 'return base report' do
        expect(comparer.base_report).to be_an_instance_of(Gitlab::Ci::Reports::CodequalityReports)
      end

      it 'return head report' do
        expect(comparer.head_report).to be_an_instance_of(Gitlab::Ci::Reports::CodequalityReports)
      end
    end
  end

  describe '#status' do
    subject(:status) { comparer.status }

    it 'returns not implemented error' do
      expect { status }.to raise_error(NotImplementedError)
    end

    context 'when success? is true' do
      before do
        allow(comparer).to receive(:success?).and_return(true)
      end

      it 'returns status success' do
        expect(status).to eq('success')
      end
    end

    context 'when success? is false' do
      before do
        allow(comparer).to receive(:success?).and_return(false)
      end

      it 'returns status failed' do
        expect(status).to eq('failed')
      end
    end
  end

  describe '#success?' do
    subject(:success?) { comparer.success? }

    it 'returns not implemented error' do
      expect { success? }.to raise_error(NotImplementedError)
    end
  end

  describe '#existing_errors' do
    subject(:existing_errors) { comparer.existing_errors }

    it 'returns not implemented error' do
      expect { existing_errors }.to raise_error(NotImplementedError)
    end
  end

  describe '#resolved_errors' do
    subject(:resolved_errors) { comparer.resolved_errors }

    it 'returns not implemented error' do
      expect { resolved_errors }.to raise_error(NotImplementedError)
    end
  end

  describe '#errors_count' do
    subject(:errors_count) { comparer.errors_count }

    it 'returns not implemented error' do
      expect { errors_count }.to raise_error(NotImplementedError)
    end
  end

  describe '#resolved_count' do
    subject(:resolved_count) { comparer.resolved_count }

    it 'returns not implemented error' do
      expect { resolved_count }.to raise_error(NotImplementedError)
    end
  end

  describe '#total_count' do
    subject(:total_count) { comparer.total_count }

    it 'returns not implemented error' do
      expect { total_count }.to raise_error(NotImplementedError)
    end
  end
end