diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-25 18:06:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-25 18:06:45 +0300 |
commit | ed9c54b56af280cc552aaac1cfa55533c900c1be (patch) | |
tree | 99605e6980c1673566fe7f293f9e4fe8dcdc4416 /spec/lib/gitlab/ci | |
parent | 8f1f6b374b69fd6356bdc5561d56f5ca9db9fadd (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/default_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/environment_spec.rb | 24 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb | 56 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 22 |
4 files changed, 103 insertions, 1 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/default_spec.rb b/spec/lib/gitlab/ci/config/entry/default_spec.rb index 0366a63ef05..ffd24aa56b9 100644 --- a/spec/lib/gitlab/ci/config/entry/default_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/default_spec.rb @@ -27,7 +27,7 @@ describe Gitlab::Ci::Config::Entry::Default do expect(described_class.nodes.keys) .to match_array(%i[before_script image services after_script cache interruptible - timeout]) + timeout retry]) end end end diff --git a/spec/lib/gitlab/ci/config/entry/environment_spec.rb b/spec/lib/gitlab/ci/config/entry/environment_spec.rb index 7b72b45fd8d..c80b54bd6be 100644 --- a/spec/lib/gitlab/ci/config/entry/environment_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/environment_spec.rb @@ -241,4 +241,28 @@ describe Gitlab::Ci::Config::Entry::Environment do end end end + + describe 'kubernetes' do + let(:config) do + { name: 'production', kubernetes: kubernetes_config } + end + + context 'is a string' do + let(:kubernetes_config) { 'production' } + + it { expect(entry).not_to be_valid } + end + + context 'is a hash' do + let(:kubernetes_config) { Hash(namespace: 'production') } + + it { expect(entry).to be_valid } + end + + context 'is nil' do + let(:kubernetes_config) { nil } + + it { expect(entry).to be_valid } + end + end end diff --git a/spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb b/spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb new file mode 100644 index 00000000000..468e83ec506 --- /dev/null +++ b/spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Ci::Config::Entry::Kubernetes do + subject { described_class.new(config) } + + describe 'attributes' do + it { is_expected.to respond_to(:namespace) } + it { is_expected.to respond_to(:has_namespace?) } + end + + describe 'validations' do + describe 'config' do + context 'is a hash containing known keys' do + let(:config) { Hash(namespace: 'namespace') } + + it { is_expected.to be_valid } + end + + context 'is a hash containing an unknown key' do + let(:config) { Hash(unknown: 'attribute') } + + it { is_expected.not_to be_valid } + end + + context 'is a string' do + let(:config) { 'config' } + + it { is_expected.not_to be_valid } + end + end + + describe 'namespace' do + let(:config) { Hash(namespace: namespace) } + + context 'is a string' do + let(:namespace) { 'namespace' } + + it { is_expected.to be_valid } + end + + context 'is a hash' do + let(:namespace) { Hash(key: 'namespace') } + + it { is_expected.not_to be_valid } + end + + context 'is not present' do + let(:namespace) { '' } + + it { is_expected.not_to be_valid } + 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 66f6402b9a2..5dc51f83b3c 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -149,6 +149,28 @@ module Gitlab expect(subject[:options]).not_to have_key(:retry) end end + + context 'when retry count is specified by default' do + let(:config) do + YAML.dump(default: { retry: { max: 1 } }, + rspec: { script: 'rspec' }) + end + + it 'does use the default value' do + expect(subject[:options]).to include(retry: { max: 1 }) + end + end + + context 'when retry count default value is overridden' do + let(:config) do + YAML.dump(default: { retry: { max: 1 } }, + rspec: { script: 'rspec', retry: { max: 2 } }) + end + + it 'does use the job value' do + expect(subject[:options]).to include(retry: { max: 2 }) + end + end end describe 'allow failure entry' do |