2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::Kubernetes::Helm::ResetCommand do
|
2020-10-24 23:57:45 +05:30
|
|
|
subject(:reset_command) { described_class.new(name: name, rbac: rbac, files: files) }
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
let(:rbac) { true }
|
|
|
|
let(:name) { 'helm' }
|
|
|
|
let(:files) { {} }
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
it_behaves_like 'helm command generator' do
|
2019-10-12 21:52:04 +05:30
|
|
|
let(:commands) do
|
|
|
|
<<~EOS
|
|
|
|
helm reset
|
|
|
|
kubectl delete replicaset -n gitlab-managed-apps -l name\\=tiller
|
2019-12-21 20:55:43 +05:30
|
|
|
kubectl delete clusterrolebinding tiller-admin
|
2019-10-12 21:52:04 +05:30
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is a ca.pem file' do
|
|
|
|
let(:files) { { 'ca.pem': 'some file content' } }
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
it_behaves_like 'helm command generator' do
|
2019-10-12 21:52:04 +05:30
|
|
|
let(:commands) do
|
|
|
|
<<~EOS1.squish + "\n" + <<~EOS2
|
|
|
|
helm reset
|
|
|
|
--tls
|
|
|
|
--tls-ca-cert /data/helm/helm/config/ca.pem
|
|
|
|
--tls-cert /data/helm/helm/config/cert.pem
|
|
|
|
--tls-key /data/helm/helm/config/key.pem
|
|
|
|
EOS1
|
|
|
|
kubectl delete replicaset -n gitlab-managed-apps -l name\\=tiller
|
2019-12-21 20:55:43 +05:30
|
|
|
kubectl delete clusterrolebinding tiller-admin
|
2019-10-12 21:52:04 +05:30
|
|
|
EOS2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#pod_name' do
|
|
|
|
subject { reset_command.pod_name }
|
|
|
|
|
|
|
|
it { is_expected.to eq('uninstall-helm') }
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
it_behaves_like 'helm command' do
|
|
|
|
let(:command) { reset_command }
|
|
|
|
end
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|