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-12-19 18:07:55 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-19 18:07:55 +0300
commitf92a53a216e6e7d5037ac701efbee5628f91aa9a (patch)
tree1eb957f0277b50002258681f61db869a2b683fec /spec/lib/gitlab/ci
parente3764d340e2849fccee8c06278d1f5f686edd35b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r--spec/lib/gitlab/ci/pipeline/seed/build/resource_group_spec.rb46
-rw-r--r--spec/lib/gitlab/ci/pipeline/seed/build_spec.rb9
-rw-r--r--spec/lib/gitlab/ci/yaml_processor_spec.rb15
3 files changed, 70 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/seed/build/resource_group_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build/resource_group_spec.rb
new file mode 100644
index 00000000000..bf6985156d3
--- /dev/null
+++ b/spec/lib/gitlab/ci/pipeline/seed/build/resource_group_spec.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::Ci::Pipeline::Seed::Build::ResourceGroup do
+ let_it_be(:project) { create(:project) }
+ let(:job) { build(:ci_build, project: project) }
+ let(:seed) { described_class.new(job, resource_group_key) }
+
+ describe '#to_resource' do
+ subject { seed.to_resource }
+
+ context 'when resource group key is specified' do
+ let(:resource_group_key) { 'iOS' }
+
+ it 'returns a resource group object' do
+ is_expected.to be_a(Ci::ResourceGroup)
+ expect(subject.key).to eq('iOS')
+ end
+
+ context 'when environment has an invalid URL' do
+ let(:resource_group_key) { ':::' }
+
+ it 'returns nothing' do
+ is_expected.to be_nil
+ end
+ end
+
+ context 'when there is a resource group already' do
+ let!(:resource_group) { create(:ci_resource_group, project: project, key: 'iOS') }
+
+ it 'does not create a new resource group' do
+ expect { subject }.not_to change { Ci::ResourceGroup.count }
+ end
+ end
+ end
+
+ context 'when resource group key is nil' do
+ let(:resource_group_key) { nil }
+
+ it 'returns nothing' do
+ is_expected.to be_nil
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
index 2ae513aea1b..5526ec9e16f 100644
--- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
@@ -231,6 +231,15 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end
end
end
+
+ context 'when job belongs to a resource group' do
+ let(:attributes) { { name: 'rspec', ref: 'master', resource_group_key: 'iOS' } }
+
+ it 'returns a job with resource group' do
+ expect(subject.resource_group).not_to be_nil
+ expect(subject.resource_group.key).to eq('iOS')
+ end
+ end
end
context 'when job is a bridge' do
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb
index 8f9c5c74260..f61b28b06c8 100644
--- a/spec/lib/gitlab/ci/yaml_processor_spec.rb
+++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb
@@ -241,6 +241,21 @@ module Gitlab
end
end
end
+
+ describe 'resource group' do
+ context 'when resource group is defined' do
+ let(:config) do
+ YAML.dump(rspec: {
+ script: 'test',
+ resource_group: 'iOS'
+ })
+ end
+
+ it 'has the attributes' do
+ expect(subject[:resource_group_key]).to eq 'iOS'
+ end
+ end
+ end
end
describe '#stages_attributes' do