blob: 9f6108a328d800d98cfd635c497ff8a9643c8356 (
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
|
# frozen_string_literal: true
require 'fast_spec_helper'
RSpec.describe Gitlab::Ci::Interpolation::Access, feature_category: :pipeline_authoring do
subject { described_class.new(access, ctx) }
let(:access) do
'inputs.data'
end
let(:ctx) do
{ inputs: { data: 'abcd' }, env: { 'ENV' => 'dev' } }
end
it 'properly evaluates the access pattern' do
expect(subject.value).to eq 'abcd'
end
context 'when there are too many objects in the access path' do
let(:access) { 'a.b.c.d.e.f.g.h' }
it 'only support MAX_ACCESS_OBJECTS steps' do
expect(subject.objects.count).to eq 5
end
end
context 'when access expression size is too large' do
before do
stub_const("#{described_class}::MAX_ACCESS_BYTESIZE", 10)
end
it 'returns an error' do
expect(subject).not_to be_valid
expect(subject.errors.first)
.to eq 'maximum interpolation expression size exceeded'
end
end
context 'when there are not enough objects in the access path' do
let(:access) { 'abc[123]' }
it 'returns an error when there are no objects found' do
expect(subject).not_to be_valid
expect(subject.errors.first)
.to eq 'invalid interpolation access pattern'
end
end
end
|