blob: 64f35c3f464f9972127aa4838db9d9a71189d34e (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Ci::Build::Status::Reason do
let(:build) { double('build') }
describe '.fabricate' do
context 'when failure symbol reason is being passed' do
it 'correctly fabricates a status reason object' do
reason = described_class.fabricate(build, :script_failure)
expect(reason.failure_reason_enum).to eq 1
end
end
context 'when another status reason object is being passed' do
it 'correctly fabricates a status reason object' do
reason = described_class.fabricate(build, :script_failure)
new_reason = described_class.fabricate(build, reason)
expect(new_reason.failure_reason_enum).to eq 1
end
end
end
describe '#failure_reason_enum' do
it 'exposes a failure reason enum' do
reason = described_class.fabricate(build, :script_failure)
enum = ::CommitStatus.failure_reasons[:script_failure]
expect(reason.failure_reason_enum).to eq enum
end
end
describe '#force_allow_failure?' do
context 'when build is not allowed to fail' do
context 'when build is allowed to fail with a given exit code' do
it 'returns true' do
reason = described_class.new(build, :script_failure, 11)
allow(build).to receive(:allow_failure?).and_return(false)
allow(build).to receive(:allowed_to_fail_with_code?)
.with(11)
.and_return(true)
expect(reason.force_allow_failure?).to be true
end
end
context 'when build is not allowed to fail regardless of an exit code' do
it 'returns false' do
reason = described_class.new(build, :script_failure, 11)
allow(build).to receive(:allow_failure?).and_return(false)
allow(build).to receive(:allowed_to_fail_with_code?)
.with(11)
.and_return(false)
expect(reason.force_allow_failure?).to be false
end
end
context 'when an exit code is not specified' do
it 'returns false' do
reason = described_class.new(build, :script_failure)
expect(reason.force_allow_failure?).to be false
end
end
end
end
end
|