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-12 09:07:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 09:07:42 +0300
commit8e22ef10e4f9c6d1ef2411aa26ddd0658e2f1461 (patch)
tree1ffd5ffed59b0f752fc358524f4d2170f6694cb9 /spec/lib/gitlab/ci
parent2ccde70b80730fd52f75797e7d711748fb5b769b (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 ff8849f84d5..fc57341b5bc 100644
--- a/spec/lib/gitlab/ci/yaml_processor_spec.rb
+++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb
@@ -239,6 +239,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