blob: 7ed9270e9a00feb222cdc46f3cb37b0d5e25cf49 (
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# 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
context 'when base_report is nil' do
let(:base_report) { nil }
it 'returns status not_found' do
expect(status).to eq('not_found')
end
end
context 'when head_report is nil' do
let(:head_report) { nil }
it 'returns status not_found' do
expect(status).to eq('not_found')
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
describe '#not_found?' do
subject(:not_found) { comparer.not_found? }
context 'when base report is nil' do
let(:base_report) { nil }
it { is_expected.to be_truthy }
end
context 'when base report exists' do
before do
allow(comparer).to receive(:success?).and_return(true)
end
it { is_expected.to be_falsey }
end
end
end
|