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 @@
require 'spec_helper'
RSpec.describe Quality::KubernetesClient do
let(:namespace) { 'review-apps-ee' }
let(:release_name) { 'my-release' }
subject { described_class.new(namespace: namespace) }
subject { described_class.new(namespace: 'review-apps-ee') }
describe '#cleanup' do
it 'calls helm list with default arguments' do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([
%(kubectl),
%(-n "#{namespace}" get ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa 2>&1),
'|',
%(grep "#{release_name}"),
'|',
"awk '{print $1}'",
'|',
%(xargs kubectl -n "#{namespace}" delete),
'||',
'true'
])
.and_return(Gitlab::Popen::Result.new([], ''))
it 'calls kubectl with the correct arguments' do
# popen_with_detail will receive an array with a bunch of arguments; we're
# only concerned with it having the correct namespace and release name
expect(Gitlab::Popen).to receive(:popen_with_detail) do |args|
expect(args)
.to satisfy_one { |arg| arg.start_with?('-n "review-apps-ee" get') }
expect(args)
.to satisfy_one { |arg| arg == 'grep "my-release"' }
expect(args)
.to satisfy_one { |arg| arg.end_with?('-n "review-apps-ee" delete') }
end
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
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