Commit 0d5e6536 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Fix the test and implement missing update

parent 02ff4381
......@@ -327,6 +327,8 @@ module Ci
@ci_yaml_file = begin
project.repository.gitlab_ci_yml_for(sha, ci_yaml_file_path)
rescue
self.yaml_errors =
"Failed to load CI/CD config file at #{ci_yaml_file_path}"
nil
end
end
......
......@@ -744,31 +744,45 @@ describe Ci::Pipeline, models: true do
describe 'yaml config file resolution' do
let(:project) { FactoryGirl.build(:project) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
it 'uses custom ci config file path when present' do
allow(project).to receive(:ci_config_file) { 'custom/path' }
expect(pipeline.ci_yaml_file_path).to eq('custom/path/.gitlab-ci.yml')
end
it 'uses root when custom path is nil' do
allow(project).to receive(:ci_config_file) { nil }
expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml')
end
it 'uses root when custom path is empty' do
allow(project).to receive(:ci_config_file) { '' }
expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml')
end
it 'allows custom filename' do
allow(project).to receive(:ci_config_file) { 'custom/path/.my-config.yml' }
expect(pipeline.ci_yaml_file_path).to eq('custom/path/.my-config.yml')
end
it 'custom filename must be yml' do
allow(project).to receive(:ci_config_file) { 'custom/path/.my-config.cnf' }
expect(pipeline.ci_yaml_file_path).to eq('custom/path/.my-config.cnf/.gitlab-ci.yml')
end
it 'reports error if the file is not found' do
allow(project).to receive(:ci_config_file) { 'custom' }
pipeline.ci_yaml_file
expect(pipeline.yaml_errors).to eq('Failed to load CI config file')
expect(pipeline.yaml_errors)
.to eq('Failed to load CI/CD config file at custom/.gitlab-ci.yml')
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment