diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-11 18:07:38 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-11 18:07:38 +0300 |
commit | 4eea104c69e59f6fa53c7bc15b986c69f29b60c8 (patch) | |
tree | 2eff1ce7ac4a58de15b1f5980acfdb22c7b92ac0 /spec/lib/gitlab/ci | |
parent | b86f474bf51e20d2db4cf0895d0a8e0894e31c08 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb b/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb index 74fa2be5930..2493855f851 100644 --- a/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb +++ b/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb @@ -128,6 +128,47 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do subject end + + context 'the build has a namespace configured via CI template' do + let(:kubernetes_namespace) { double(namespace: existing_namespace) } + + before do + allow(build).to receive(:expanded_kubernetes_namespace) + .and_return(requested_namespace) + end + + context 'the requested namespace matches the default' do + let(:requested_namespace) { 'production' } + let(:existing_namespace) { requested_namespace } + + it 'creates a namespace' do + expect(Clusters::BuildKubernetesNamespaceService) + .to receive(:new) + .with(cluster, environment: deployment.environment) + .and_return(namespace_builder) + + expect(Clusters::Kubernetes::CreateOrUpdateNamespaceService) + .to receive(:new) + .with(cluster: cluster, kubernetes_namespace: kubernetes_namespace) + .and_return(service) + + expect(service).to receive(:execute).once + + subject + end + end + + context 'the requested namespace differs from the default' do + let(:requested_namespace) { 'production' } + let(:existing_namespace) { 'other-namespace' } + + it 'does not create a namespace' do + expect(Clusters::Kubernetes::CreateOrUpdateNamespaceService).not_to receive(:new) + + subject + end + end + end end context 'kubernetes namespace exists (but has no service_account_token)' do |