diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-17 06:08:39 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-17 06:08:39 +0000 |
commit | ea20020f71c7226d57b6449b1d9b6c6f1298223e (patch) | |
tree | 8e33029cf61ae40635dde3fc5c1567dda8d14d18 /spec/lib | |
parent | d9e821dbd908f40ff9828357452cd55a651283fa (diff) | |
download | gitlab-ce-ea20020f71c7226d57b6449b1d9b6c6f1298223e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/kubernetes/helm/api_spec.rb | 11 | ||||
-rw-r--r-- | spec/lib/gitlab/kubernetes/namespace_spec.rb | 14 |
2 files changed, 21 insertions, 4 deletions
diff --git a/spec/lib/gitlab/kubernetes/helm/api_spec.rb b/spec/lib/gitlab/kubernetes/helm/api_spec.rb index 5d9beec093a..e493acd7bad 100644 --- a/spec/lib/gitlab/kubernetes/helm/api_spec.rb +++ b/spec/lib/gitlab/kubernetes/helm/api_spec.rb @@ -6,7 +6,8 @@ describe Gitlab::Kubernetes::Helm::Api do let(:client) { double('kubernetes client') } let(:helm) { described_class.new(client) } let(:gitlab_namespace) { Gitlab::Kubernetes::Helm::NAMESPACE } - let(:namespace) { Gitlab::Kubernetes::Namespace.new(gitlab_namespace, client) } + let(:gitlab_namespace_labels) { Gitlab::Kubernetes::Helm::NAMESPACE_LABELS } + let(:namespace) { Gitlab::Kubernetes::Namespace.new(gitlab_namespace, client, labels: gitlab_namespace_labels) } let(:application_name) { 'app-name' } let(:rbac) { false } let(:files) { {} } @@ -23,13 +24,17 @@ describe Gitlab::Kubernetes::Helm::Api do subject { helm } before do - allow(Gitlab::Kubernetes::Namespace).to receive(:new).with(gitlab_namespace, client).and_return(namespace) + allow(Gitlab::Kubernetes::Namespace).to( + receive(:new).with(gitlab_namespace, client, labels: gitlab_namespace_labels).and_return(namespace) + ) allow(client).to receive(:create_config_map) end describe '#initialize' do it 'creates a namespace object' do - expect(Gitlab::Kubernetes::Namespace).to receive(:new).with(gitlab_namespace, client) + expect(Gitlab::Kubernetes::Namespace).to( + receive(:new).with(gitlab_namespace, client, labels: gitlab_namespace_labels) + ) subject end diff --git a/spec/lib/gitlab/kubernetes/namespace_spec.rb b/spec/lib/gitlab/kubernetes/namespace_spec.rb index 16634cc48e6..d44a803410f 100644 --- a/spec/lib/gitlab/kubernetes/namespace_spec.rb +++ b/spec/lib/gitlab/kubernetes/namespace_spec.rb @@ -5,8 +5,9 @@ require 'spec_helper' describe Gitlab::Kubernetes::Namespace do let(:name) { 'a_namespace' } let(:client) { double('kubernetes client') } + let(:labels) { nil } - subject { described_class.new(name, client) } + subject { described_class.new(name, client, labels: labels) } it { expect(subject.name).to eq(name) } @@ -49,6 +50,17 @@ describe Gitlab::Kubernetes::Namespace do expect { subject.create! }.not_to raise_error end + + context 'with labels' do + let(:labels) { { foo: :bar } } + + it 'creates a namespace with labels' do + matcher = have_attributes(metadata: have_attributes(name: name, labels: have_attributes(foo: :bar))) + expect(client).to receive(:create_namespace).with(matcher).once + + expect { subject.create! }.not_to raise_error + end + end end describe '#ensure_exists!' do |