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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Ci::Config::External::Mapper::LocationExpander, feature_category: :pipeline_authoring do
include RepoHelpers
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner }
let(:sha) { project.commit.sha }
let(:context) do
Gitlab::Ci::Config::External::Context.new(project: project, user: user, sha: sha)
end
subject(:location_expander) { described_class.new(context) }
describe '#process' do
subject(:process) { location_expander.process(locations) }
context 'when there are project files' do
let(:locations) do
[{ project: 'gitlab-org/gitlab-1', file: ['builds.yml', 'tests.yml'] },
{ project: 'gitlab-org/gitlab-2', file: 'deploy.yml' }]
end
it 'returns expanded locations' do
is_expected.to eq(
[{ project: 'gitlab-org/gitlab-1', file: 'builds.yml' },
{ project: 'gitlab-org/gitlab-1', file: 'tests.yml' },
{ project: 'gitlab-org/gitlab-2', file: 'deploy.yml' }]
)
end
end
context 'when there are local files' do
let(:locations) do
[{ local: 'builds/*.yml' },
{ local: 'tests.yml' }]
end
let(:project_files) do
{ 'builds/1.yml' => 'a', 'builds/2.yml' => 'b', 'tests.yml' => 'c' }
end
around do |example|
create_and_delete_files(project, project_files) do
example.run
end
end
it 'returns expanded locations' do
is_expected.to eq(
[{ local: 'builds/1.yml' },
{ local: 'builds/2.yml' },
{ local: 'tests.yml' }]
)
end
end
context 'when there are other files' do
let(:locations) do
[{ remote: 'https://gitlab.com/gitlab-org/gitlab-ce/raw/master/.gitlab-ci.yml' }]
end
it 'returns the same location' do
is_expected.to eq(locations)
end
end
end
end
|