2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe 'CI YML Templates' do
|
2019-07-31 22:56:46 +05:30
|
|
|
subject { Gitlab::Ci::YamlProcessor.new(content) }
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
let(:all_templates) { Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name) }
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
let(:disabled_templates) do
|
|
|
|
Gitlab::Template::GitlabCiYmlTemplate.disabled_templates.map do |template|
|
|
|
|
template + Gitlab::Template::GitlabCiYmlTemplate.extension
|
2019-07-31 22:56:46 +05:30
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'included in a CI YAML configuration' do
|
|
|
|
using RSpec::Parameterized::TableSyntax
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
where(:template_name) do
|
|
|
|
all_templates - disabled_templates
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
with_them do
|
|
|
|
let(:content) do
|
|
|
|
<<~EOS
|
|
|
|
include:
|
|
|
|
- template: #{template_name}
|
|
|
|
|
|
|
|
concrete_build_implemented_by_a_user:
|
|
|
|
stage: test
|
|
|
|
script: do something
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is valid' do
|
|
|
|
expect { subject }.not_to raise_error
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'require default stages to be included' do
|
|
|
|
expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default)
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|