diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-25 15:06:45 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-25 15:06:45 +0000 |
commit | ed9c54b56af280cc552aaac1cfa55533c900c1be (patch) | |
tree | 99605e6980c1673566fe7f293f9e4fe8dcdc4416 /spec/lib/gitlab/ci/config | |
parent | 8f1f6b374b69fd6356bdc5561d56f5ca9db9fadd (diff) | |
download | gitlab-ce-ed9c54b56af280cc552aaac1cfa55533c900c1be.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci/config')
-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 |
3 files changed, 81 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 |