Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-18 21:06:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-18 21:06:53 +0300
commit143f196f8b3c40ceb7e9335a8dcc712b079519b9 (patch)
tree909df13e1f99b456287934741ba466b506e01129 /spec/services/ci/create_pipeline_service_spec.rb
parent575ccb036ea14c6a899482a83bd985ffbc992077 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/ci/create_pipeline_service_spec.rb')
-rw-r--r--spec/services/ci/create_pipeline_service_spec.rb80
1 files changed, 80 insertions, 0 deletions
diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb
index a2169a015ee..de0f4841215 100644
--- a/spec/services/ci/create_pipeline_service_spec.rb
+++ b/spec/services/ci/create_pipeline_service_spec.rb
@@ -65,6 +65,7 @@ describe Ci::CreatePipelineService do
expect(pipeline.iid).not_to be_nil
expect(pipeline.repository_source?).to be true
expect(pipeline.builds.first).to be_kind_of(Ci::Build)
+ expect(pipeline.yaml_errors).not_to be_present
end
it 'increments the prometheus counter' do
@@ -474,6 +475,66 @@ describe Ci::CreatePipelineService do
end
end
+ context 'config evaluation' do
+ context 'when config is in a file in repository' do
+ before do
+ content = YAML.dump(rspec: { script: 'echo' })
+ stub_ci_pipeline_yaml_file(content)
+ end
+
+ it 'pull it from the repository' do
+ pipeline = execute_service
+ expect(pipeline).to be_repository_source
+ expect(pipeline.builds.map(&:name)).to eq ['rspec']
+ end
+ end
+
+ context 'when config is from Auto-DevOps' do
+ before do
+ stub_ci_pipeline_yaml_file(nil)
+ allow_any_instance_of(Project).to receive(:auto_devops_enabled?).and_return(true)
+ end
+
+ it 'pull it from Auto-DevOps' do
+ pipeline = execute_service
+ expect(pipeline).to be_auto_devops_source
+ expect(pipeline.builds.map(&:name)).to eq %w[test code_quality build]
+ end
+ end
+
+ context 'when config is not found' do
+ before do
+ stub_ci_pipeline_yaml_file(nil)
+ end
+
+ it 'attaches errors to the pipeline' do
+ pipeline = execute_service
+
+ expect(pipeline.errors.full_messages).to eq ['Missing .gitlab-ci.yml file']
+ expect(pipeline).not_to be_persisted
+ end
+ end
+
+ context 'when an unexpected error is raised' do
+ before do
+ expect(Gitlab::Ci::YamlProcessor).to receive(:new)
+ .and_raise(RuntimeError, 'undefined failure')
+ end
+
+ it 'saves error in pipeline' do
+ pipeline = execute_service
+
+ expect(pipeline.yaml_errors).to include('Undefined error')
+ end
+
+ it 'logs error' do
+ expect(Gitlab::Sentry).to receive(:track_acceptable_exception).and_call_original
+
+ execute_service
+ end
+ end
+ end
+
context 'when yaml is invalid' do
let(:ci_yaml) { 'invalid: file: fiile' }
let(:message) { 'Message' }
@@ -539,6 +600,25 @@ describe Ci::CreatePipelineService do
end
end
+ context 'when an unexpected error is raised' do
+ before do
+ expect(Gitlab::Ci::YamlProcessor).to receive(:new)
+ .and_raise(RuntimeError, 'undefined failure')
+ end
+
+ it 'saves error in pipeline' do
+ pipeline = execute_service
+
+ expect(pipeline.yaml_errors).to include('Undefined error')
+ end
+
+ it 'logs error' do
+ expect(Gitlab::Sentry).to receive(:track_acceptable_exception).and_call_original
+
+ execute_service
+ end
+ end
+
context 'when commit contains a [ci skip] directive' do
let(:message) { "some message[ci skip]" }