diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-09-26 15:39:27 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2018-09-26 15:39:27 +0000 |
commit | f5f5d6ea1f816f2d695eca74b3923457dcccbdff (patch) | |
tree | 22b25ffd74a9012f9a8cba9f597d9db4ba50719e /spec/lib | |
parent | 82ea7195cdeab1f9177796517b7267cb7db0fae0 (diff) | |
download | gitlab-ce-f5f5d6ea1f816f2d695eca74b3923457dcccbdff.tar.gz |
Resolve "Un-vendor CI templates"
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/ci/external/file/local_spec.rb | 10 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/external/mapper_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/external/processor_spec.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/templates/templates_spec.rb | 11 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb | 2 |
6 files changed, 23 insertions, 24 deletions
diff --git a/spec/lib/gitlab/ci/external/file/local_spec.rb b/spec/lib/gitlab/ci/external/file/local_spec.rb index 3f32d81a827..73bb4ccf468 100644 --- a/spec/lib/gitlab/ci/external/file/local_spec.rb +++ b/spec/lib/gitlab/ci/external/file/local_spec.rb @@ -8,7 +8,7 @@ describe Gitlab::Ci::External::File::Local do describe '#valid?' do context 'when is a valid local path' do - let(:location) { '/vendor/gitlab-ci-yml/existent-file.yml' } + let(:location) { '/lib/gitlab/ci/templates/existent-file.yml' } before do allow_any_instance_of(described_class).to receive(:fetch_local_content).and_return("image: 'ruby2:2'") @@ -20,7 +20,7 @@ describe Gitlab::Ci::External::File::Local do end context 'when is not a valid local path' do - let(:location) { '/vendor/gitlab-ci-yml/non-existent-file.yml' } + let(:location) { '/lib/gitlab/ci/templates/non-existent-file.yml' } it 'should return false' do expect(local_file.valid?).to be_falsy @@ -48,7 +48,7 @@ describe Gitlab::Ci::External::File::Local do - bundle install --jobs $(nproc) "${FLAGS[@]}" HEREDOC end - let(:location) { '/vendor/gitlab-ci-yml/existent-file.yml' } + let(:location) { '/lib/gitlab/ci/templates/existent-file.yml' } before do allow_any_instance_of(described_class).to receive(:fetch_local_content).and_return(local_file_content) @@ -60,7 +60,7 @@ describe Gitlab::Ci::External::File::Local do end context 'with an invalid file' do - let(:location) { '/vendor/gitlab-ci-yml/non-existent-file.yml' } + let(:location) { '/lib/gitlab/ci/templates/non-existent-file.yml' } it 'should be nil' do expect(local_file.content).to be_nil @@ -69,7 +69,7 @@ describe Gitlab::Ci::External::File::Local do end describe '#error_message' do - let(:location) { '/vendor/gitlab-ci-yml/non-existent-file.yml' } + let(:location) { '/lib/gitlab/ci/templates/non-existent-file.yml' } it 'should return an error message' do expect(local_file.error_message).to eq("Local file '#{location}' is not valid.") diff --git a/spec/lib/gitlab/ci/external/mapper_spec.rb b/spec/lib/gitlab/ci/external/mapper_spec.rb index 6270d27a36d..d925d6af73d 100644 --- a/spec/lib/gitlab/ci/external/mapper_spec.rb +++ b/spec/lib/gitlab/ci/external/mapper_spec.rb @@ -17,7 +17,7 @@ describe Gitlab::Ci::External::Mapper do context 'when the string is a local file' do let(:values) do { - include: '/vendor/gitlab-ci-yml/non-existent-file.yml', + include: '/lib/gitlab/ci/templates/non-existent-file.yml', image: 'ruby:2.2' } end @@ -61,7 +61,7 @@ describe Gitlab::Ci::External::Mapper do include: [ remote_url, - '/vendor/gitlab-ci-yml/template.yml' + '/lib/gitlab/ci/templates/template.yml' ], image: 'ruby:2.2' } diff --git a/spec/lib/gitlab/ci/external/processor_spec.rb b/spec/lib/gitlab/ci/external/processor_spec.rb index 688c2b3c8aa..3c7394f53d2 100644 --- a/spec/lib/gitlab/ci/external/processor_spec.rb +++ b/spec/lib/gitlab/ci/external/processor_spec.rb @@ -16,12 +16,12 @@ describe Gitlab::Ci::External::Processor do end context 'when an invalid local file is defined' do - let(:values) { { include: '/vendor/gitlab-ci-yml/non-existent-file.yml', image: 'ruby:2.2' } } + let(:values) { { include: '/lib/gitlab/ci/templates/non-existent-file.yml', image: 'ruby:2.2' } } it 'should raise an error' do expect { processor.perform }.to raise_error( described_class::FileError, - "Local file '/vendor/gitlab-ci-yml/non-existent-file.yml' is not valid." + "Local file '/lib/gitlab/ci/templates/non-existent-file.yml' is not valid." ) end end @@ -79,7 +79,7 @@ describe Gitlab::Ci::External::Processor do end context 'with a valid local external file is defined' do - let(:values) { { include: '/vendor/gitlab-ci-yml/template.yml', image: 'ruby:2.2' } } + let(:values) { { include: '/lib/gitlab/ci/templates/template.yml', image: 'ruby:2.2' } } let(:local_file_content) do <<-HEREDOC before_script: @@ -145,7 +145,7 @@ describe Gitlab::Ci::External::Processor do end context 'when external files are defined but not valid' do - let(:values) { { include: '/vendor/gitlab-ci-yml/template.yml', image: 'ruby:2.2' } } + let(:values) { { include: '/lib/gitlab/ci/templates/template.yml', image: 'ruby:2.2' } } let(:local_file_content) { 'invalid content file ////' } diff --git a/spec/lib/gitlab/ci/templates/templates_spec.rb b/spec/lib/gitlab/ci/templates/templates_spec.rb new file mode 100644 index 00000000000..0dd74399a47 --- /dev/null +++ b/spec/lib/gitlab/ci/templates/templates_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe "CI YML Templates" do + Gitlab::Template::GitlabCiYmlTemplate.all.each do |template| + it "#{template.name} should be valid" do + expect { Gitlab::Ci::YamlProcessor.new(template.content) }.not_to raise_error + end + end +end diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index fcbdf71a4e9..a2d429fa859 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1371,18 +1371,6 @@ module Gitlab end end - describe "Validate configuration templates" do - templates = Dir.glob("#{Rails.root.join('vendor/gitlab-ci-yml')}/**/*.gitlab-ci.yml") - - templates.each do |file| - it "does not return errors for #{file}" do - file = File.read(file) - - expect { Gitlab::Ci::YamlProcessor.new(file) }.not_to raise_error - end - end - end - describe "#validation_message" do subject { Gitlab::Ci::YamlProcessor.validation_message(content) } diff --git a/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb b/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb index e2fa76522bc..fe46c67a920 100644 --- a/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb +++ b/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb @@ -40,7 +40,7 @@ describe Gitlab::Template::GitlabCiYmlTemplate do describe '#content' do it 'loads the full file' do - gitignore = subject.new(Rails.root.join('vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml')) + gitignore = subject.new(Rails.root.join('lib/gitlab/ci/templates/Ruby.gitlab-ci.yml')) expect(gitignore.name).to eq 'Ruby' expect(gitignore.content).to start_with('#') |