diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-01 18:09:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-01 18:09:16 +0300 |
commit | 18d5458781b21dee4dbb8854c72c064e9bd808ed (patch) | |
tree | 73cfc86a9b77398a154ebabebc054b45d4aeb83d /spec/tooling | |
parent | a21091270d45530468f8ac2f4f926fe1b9840b67 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tooling')
-rw-r--r-- | spec/tooling/lib/tooling/helm3_client_spec.rb | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/spec/tooling/lib/tooling/helm3_client_spec.rb b/spec/tooling/lib/tooling/helm3_client_spec.rb index 52d1b5a1567..5a015ddfa7c 100644 --- a/spec/tooling/lib/tooling/helm3_client_spec.rb +++ b/spec/tooling/lib/tooling/helm3_client_spec.rb @@ -3,15 +3,14 @@ require_relative '../../../../tooling/lib/tooling/helm3_client' RSpec.describe Tooling::Helm3Client do - let(:namespace) { 'review-apps' } let(:release_name) { 'my-release' } let(:raw_helm_list_page1) do <<~OUTPUT [ - {"name":"review-qa-60-reor-1mugd1","namespace":"#{namespace}","revision":1,"updated":"2020-04-03 17:27:10.245952 +0800 +08","status":"failed","chart":"gitlab-1.1.3","app_version":"12.9.2"}, - {"name":"review-7846-fix-s-261vd6","namespace":"#{namespace}","revision":2,"updated":"2020-04-02 17:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.2"}, - {"name":"review-7867-snowp-lzo3iy","namespace":"#{namespace}","revision":1,"updated":"2020-04-02 15:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.1"}, - {"name":"review-6709-group-2pzeec","namespace":"#{namespace}","revision":2,"updated":"2020-04-01 21:27:12.245952 +0800 +08","status":"failed","chart":"gitlab-1.1.3","app_version":"12.9.1"} + {"name":"review-qa-60-reor-1mugd1","namespace":"review-qa-60-reor-1mugd1","revision":1,"updated":"2020-04-03 17:27:10.245952 +0800 +08","status":"failed","chart":"gitlab-1.1.3","app_version":"12.9.2"}, + {"name":"review-7846-fix-s-261vd6","namespace":"review-7846-fix-s-261vd6","revision":2,"updated":"2020-04-02 17:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.2"}, + {"name":"review-7867-snowp-lzo3iy","namespace":"review-7867-snowp-lzo3iy","revision":1,"updated":"2020-04-02 15:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.1"}, + {"name":"review-6709-group-2pzeec","namespace":"review-6709-group-2pzeec","revision":2,"updated":"2020-04-01 21:27:12.245952 +0800 +08","status":"failed","chart":"gitlab-1.1.3","app_version":"12.9.1"} ] OUTPUT end @@ -19,7 +18,7 @@ RSpec.describe Tooling::Helm3Client do let(:raw_helm_list_page2) do <<~OUTPUT [ - {"name":"review-6709-group-t40qbv","namespace":"#{namespace}","revision":2,"updated":"2020-04-01 11:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.1"} + {"name":"review-6709-group-t40qbv","namespace":"review-6709-group-t40qbv","revision":2,"updated":"2020-04-01 11:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.1"} ] OUTPUT end @@ -30,7 +29,7 @@ RSpec.describe Tooling::Helm3Client do OUTPUT end - subject { described_class.new(namespace: namespace) } + subject { described_class.new } describe '#releases' do it 'raises an error if the Helm command fails' do @@ -74,7 +73,7 @@ RSpec.describe Tooling::Helm3Client do status: 'deployed', chart: 'gitlab-1.1.3', app_version: '12.9.1', - namespace: namespace + namespace: 'review-6709-group-t40qbv' ) end @@ -98,18 +97,19 @@ RSpec.describe Tooling::Helm3Client do describe '#delete' do it 'raises an error if the Helm command fails' do expect(Gitlab::Popen).to receive(:popen_with_detail) - .with([%(helm uninstall #{release_name})]) + .with([%(helm uninstall --namespace #{release_name} #{release_name})]) .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: false))) - expect { subject.delete(release_name: release_name) }.to raise_error(described_class::CommandFailedError) + expect { subject.delete(release_name: release_name, namespace: release_name) } + .to raise_error(described_class::CommandFailedError) end it 'calls helm uninstall with default arguments' do expect(Gitlab::Popen).to receive(:popen_with_detail) - .with([%(helm uninstall #{release_name})]) + .with([%(helm uninstall --namespace #{release_name} #{release_name})]) .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true))) - expect(subject.delete(release_name: release_name)).to eq('') + subject.delete(release_name: release_name, namespace: release_name) end context 'with multiple release names' do @@ -117,18 +117,30 @@ RSpec.describe Tooling::Helm3Client do it 'raises an error if the Helm command fails' do expect(Gitlab::Popen).to receive(:popen_with_detail) - .with([%(helm uninstall #{release_name.join(' ')})]) + .with([%(helm uninstall --namespace #{release_name[0]} #{release_name[0]})]) .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: false))) expect { subject.delete(release_name: release_name) }.to raise_error(described_class::CommandFailedError) end - it 'calls helm uninstall with multiple release names' do - expect(Gitlab::Popen).to receive(:popen_with_detail) - .with([%(helm uninstall #{release_name.join(' ')})]) - .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true))) + it 'calls helm uninstall with multiple release names and a namespace' do + release_name.each do |release| + expect(Gitlab::Popen).to receive(:popen_with_detail) + .with([%(helm uninstall --namespace namespace #{release})]) + .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true))) + end + + subject.delete(release_name: release_name, namespace: 'namespace') + end + + it 'calls helm uninstall with multiple release names and no namespace' do + release_name.each do |release| + expect(Gitlab::Popen).to receive(:popen_with_detail) + .with([%(helm uninstall --namespace #{release} #{release})]) + .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true))) + end - expect(subject.delete(release_name: release_name)).to eq('') + subject.delete(release_name: release_name) end end end |