blob: 72a5bf8d011b1dd01eb6ef08bc67f74fd60feb83 (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Ci::Pipeline::Chain::Helpers do
let(:helper_class) do
Class.new do
include Gitlab::Ci::Pipeline::Chain::Helpers
attr_accessor :pipeline, :command
def initialize(pipeline, command)
self.pipeline = pipeline
self.command = command
end
end
end
subject(:helper) { helper_class.new(pipeline, command) }
let(:pipeline) { build(:ci_empty_pipeline) }
let(:command) { double(save_incompleted: true) }
let(:message) { 'message' }
describe '.error' do
shared_examples 'error function' do
specify do
expect(pipeline).to receive(:drop!).with(drop_reason).and_call_original
expect(pipeline).to receive(:add_error_message).with(message).and_call_original
expect(pipeline).to receive(:ensure_project_iid!).twice.and_call_original
subject.error(message, config_error: config_error, drop_reason: drop_reason)
expect(pipeline.yaml_errors).to eq(yaml_error)
expect(pipeline.errors[:base]).to include(message)
end
end
context 'when given a drop reason' do
context 'when config error is true' do
context 'sets the yaml error and overrides the drop reason' do
let(:drop_reason) { :config_error }
let(:config_error) { true }
let(:yaml_error) { message }
it_behaves_like "error function"
end
end
context 'when config error is false' do
context 'does not set the yaml error or override the drop reason' do
let(:drop_reason) { :size_limit_exceeded }
let(:config_error) { false }
let(:yaml_error) { nil }
it_behaves_like "error function"
end
end
end
context 'when the ci_pipeline_ensure_iid_on_drop feature flag is false' do
it 'does not ensure the project iid' do
stub_feature_flags(ci_pipeline_ensure_iid_on_drop: false)
expect(pipeline).to receive(:ensure_project_iid!).once
subject.error(message, config_error: true)
end
end
end
end
|