Commit 6a6c0f05 authored by Robert Speicher's avatar Robert Speicher

Simplify the KubernetesClient spec

Only verify the arguments we actually care about.
parent f205d099
...@@ -3,29 +3,23 @@ ...@@ -3,29 +3,23 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Quality::KubernetesClient do RSpec.describe Quality::KubernetesClient do
let(:namespace) { 'review-apps-ee' } subject { described_class.new(namespace: 'review-apps-ee') }
let(:release_name) { 'my-release' }
subject { described_class.new(namespace: namespace) }
describe '#cleanup' do describe '#cleanup' do
it 'calls helm list with default arguments' do it 'calls kubectl with the correct arguments' do
expect(Gitlab::Popen).to receive(:popen_with_detail) # popen_with_detail will receive an array with a bunch of arguments; we're
.with([ # only concerned with it having the correct namespace and release name
%(kubectl), expect(Gitlab::Popen).to receive(:popen_with_detail) do |args|
%(-n "#{namespace}" get ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa 2>&1), expect(args)
'|', .to satisfy_one { |arg| arg.start_with?('-n "review-apps-ee" get') }
%(grep "#{release_name}"), expect(args)
'|', .to satisfy_one { |arg| arg == 'grep "my-release"' }
"awk '{print $1}'", expect(args)
'|', .to satisfy_one { |arg| arg.end_with?('-n "review-apps-ee" delete') }
%(xargs kubectl -n "#{namespace}" delete), end
'||',
'true'
])
.and_return(Gitlab::Popen::Result.new([], ''))
subject.cleanup(release_name: release_name) # We're not verifying the output here, just silencing it
expect { subject.cleanup(release_name: 'my-release') }.to output.to_stdout
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment