blob: 27d93d555f10421fe6f4aaa656df4d6934653ad0 (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Ci::Config::Yaml, feature_category: :pipeline_composition do
let(:yaml) do
<<~YAML
image: 'image:1.0'
texts:
nested_key: 'value1'
more_text:
more_nested_key: 'value2'
YAML
end
describe '.load!' do
subject(:config) { described_class.load!(yaml) }
it 'loads a YAML file' do
expect(config).to eq({
image: 'image:1.0',
texts: {
nested_key: 'value1',
more_text: {
more_nested_key: 'value2'
}
}
})
end
context 'when YAML is invalid' do
let(:yaml) { 'some: invalid: syntax' }
it 'raises an error' do
expect { config }
.to raise_error ::Gitlab::Config::Loader::FormatError, /mapping values are not allowed in this context/
end
end
context 'when given a user' do
let(:user) { instance_double(User) }
subject(:config) { described_class.load!(yaml, current_user: user) }
it 'passes it to Loader' do
expect(::Gitlab::Ci::Config::Yaml::Loader).to receive(:new).with(yaml, current_user: user).and_call_original
config
end
end
end
end
|