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-01 15:06:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-01 15:06:26 +0300
commitdeed6022efe0149d88c57ef1df736c83465643f9 (patch)
tree4cf4c7c1ce765e83547129607b6bd3881c0fad6b /spec/lib/gitlab/ci
parentf7a13c56bf0ed7ff9591bf4cbf9e50487255c4bc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r--spec/lib/gitlab/ci/config/entry/job_spec.rb17
-rw-r--r--spec/lib/gitlab/ci/config/entry/need_spec.rb36
-rw-r--r--spec/lib/gitlab/ci/config/entry/needs_spec.rb84
-rw-r--r--spec/lib/gitlab/ci/yaml_processor_spec.rb15
4 files changed, 29 insertions, 123 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb
index 9fe18caf689..d3eb5a9663f 100644
--- a/spec/lib/gitlab/ci/config/entry/job_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb
@@ -23,7 +23,7 @@ describe Gitlab::Ci::Config::Entry::Job do
let(:result) do
%i[before_script script stage type after_script cache
- image services only except rules needs variables artifacts
+ image services only except rules variables artifacts
environment coverage retry]
end
@@ -384,6 +384,21 @@ describe Gitlab::Ci::Config::Entry::Job do
end
context 'when has needs' do
+ context 'that are not a array of strings' do
+ let(:config) do
+ {
+ stage: 'test',
+ script: 'echo',
+ needs: 'build-job'
+ }
+ end
+
+ it 'returns error about invalid type' do
+ expect(entry).not_to be_valid
+ expect(entry.errors).to include 'job needs should be an array of strings'
+ end
+ end
+
context 'when have dependencies that are not subset of needs' do
let(:config) do
{
diff --git a/spec/lib/gitlab/ci/config/entry/need_spec.rb b/spec/lib/gitlab/ci/config/entry/need_spec.rb
deleted file mode 100644
index d119e604900..00000000000
--- a/spec/lib/gitlab/ci/config/entry/need_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe ::Gitlab::Ci::Config::Entry::Need do
- subject(:need) { described_class.new(config) }
-
- context 'when job is specified' do
- let(:config) { 'job_name' }
-
- describe '#valid?' do
- it { is_expected.to be_valid }
- end
-
- describe '#value' do
- it 'returns job needs configuration' do
- expect(need.value).to eq(name: 'job_name')
- end
- end
- end
-
- context 'when need is empty' do
- let(:config) { '' }
-
- describe '#valid?' do
- it { is_expected.not_to be_valid }
- end
-
- describe '#errors' do
- it 'is returns an error about an empty config' do
- expect(need.errors)
- .to contain_exactly("job config can't be blank")
- end
- end
- end
-end
diff --git a/spec/lib/gitlab/ci/config/entry/needs_spec.rb b/spec/lib/gitlab/ci/config/entry/needs_spec.rb
deleted file mode 100644
index f4a76b52d30..00000000000
--- a/spec/lib/gitlab/ci/config/entry/needs_spec.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe ::Gitlab::Ci::Config::Entry::Needs do
- subject(:needs) { described_class.new(config) }
-
- before do
- needs.metadata[:allowed_needs] = %i[job]
- end
-
- describe 'validations' do
- before do
- needs.compose!
- end
-
- context 'when entry config value is correct' do
- let(:config) { ['job_name'] }
-
- describe '#valid?' do
- it { is_expected.to be_valid }
- end
- end
-
- context 'when config value has wrong type' do
- let(:config) { 123 }
-
- describe '#valid?' do
- it { is_expected.not_to be_valid }
- end
-
- describe '#errors' do
- it 'returns error about incorrect type' do
- expect(needs.errors)
- .to include('needs config can only be a hash or an array')
- end
- end
- end
-
- context 'when wrong needs type is used' do
- let(:config) { [123] }
-
- describe '#valid?' do
- it { is_expected.not_to be_valid }
- end
-
- describe '#errors' do
- it 'returns error about incorrect type' do
- expect(needs.errors).to contain_exactly(
- 'need has an unsupported type')
- end
- end
- end
- end
-
- describe '.compose!' do
- context 'when valid job entries composed' do
- let(:config) { %w[first_job_name second_job_name] }
-
- before do
- needs.compose!
- end
-
- describe '#value' do
- it 'returns key value' do
- expect(needs.value).to eq(
- job: [
- { name: 'first_job_name' },
- { name: 'second_job_name' }
- ]
- )
- end
- end
-
- describe '#descendants' do
- it 'creates valid descendant nodes' do
- expect(needs.descendants.count).to eq 2
- expect(needs.descendants)
- .to all(be_an_instance_of(::Gitlab::Ci::Config::Entry::Need))
- end
- end
- end
- end
-end
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb
index c7ea6ed9ddb..c747ea670bb 100644
--- a/spec/lib/gitlab/ci/yaml_processor_spec.rb
+++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb
@@ -1293,7 +1293,7 @@ module Gitlab
end
end
- describe "Job Needs" do
+ describe "Needs" do
let(:needs) { }
let(:dependencies) { }
@@ -1333,7 +1333,12 @@ module Gitlab
stage: "test",
stage_idx: 2,
name: "test1",
- options: { script: ["test"] },
+ options: {
+ script: ["test"],
+ # This does not make sense, there is a follow-up:
+ # https://gitlab.com/gitlab-org/gitlab-foss/issues/65569
+ bridge_needs: %w[build1 build2]
+ },
needs_attributes: [
{ name: "build1" },
{ name: "build2" }
@@ -1345,6 +1350,12 @@ module Gitlab
end
end
+ context 'needs two builds defined as symbols' do
+ let(:needs) { [:build1, :build2] }
+
+ it { expect { subject }.not_to raise_error }
+ end
+
context 'undefined need' do
let(:needs) { ['undefined'] }