Adding spec test to ensure that all the interfaces are the same, while doing so, fix the broken interfaces for delete on vmpooler and nonstandard pooler(they were passed 5 by service.rb but expected 4)

This commit is contained in:
Mikker Gimenez-Peterson 2020-01-14 09:39:49 -08:00
parent bc1198f81c
commit dc3bfecd28
6 changed files with 57 additions and 6 deletions

View file

@ -274,7 +274,7 @@ describe NonstandardPooler do
.with(:headers => @auth_token_headers)
.to_return(:status => 200, :body => @delete_response_success, :headers => {})
request = NonstandardPooler.delete(false, @nspooler_url, 'sol11-7', 'token-value')
request = NonstandardPooler.delete(false, @nspooler_url, 'sol11-7', 'token-value', nil)
expect(request['sol11-7']['ok']).to be true
end
@ -283,7 +283,7 @@ describe NonstandardPooler do
.with(:headers => @auth_token_headers)
.to_return(:status => 401, :body => @delete_response_failure, :headers => {})
request = NonstandardPooler.delete(false, @nspooler_url, 'fakehost', 'token-value')
request = NonstandardPooler.delete(false, @nspooler_url, 'fakehost', 'token-value', nil)
expect(request['fakehost']['ok']).to be false
end
end

View file

@ -119,11 +119,11 @@ describe Pooler do
.with(:headers => { 'X-Auth-Token' => 'mytokenfile' })
.to_return(:status => 200, :body => @delete_response_body_success, :headers => {})
expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile')).to eq @delete_response
expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile', nil)).to eq @delete_response
end
it 'raises a token error if no token provided' do
expect { Pooler.delete(false, @vmpooler_url, ['myfakehost'], nil) }.to raise_error(TokenError)
expect { Pooler.delete(false, @vmpooler_url, ['myfakehost'], nil, nil) }.to raise_error(TokenError)
end
end

View file

@ -0,0 +1,39 @@
# frozen_string_literal: true
# All of the interfaces for the different services must be the
# same, otherwise there will be errors when you change the caller
# for the services from services.rb.
#
require_relative '../../lib/vmfloaty/pooler'
require_relative '../../lib/vmfloaty/abs'
require_relative '../../lib/vmfloaty/nonstandard_pooler'
shared_examples 'a vmfloaty service' do
it { is_expected.to respond_to(:delete).with(5).arguments }
it { is_expected.to respond_to(:disk).with(5).arguments }
it { is_expected.to respond_to(:list).with(3).arguments }
it { is_expected.to respond_to(:list_active).with(4).arguments }
it { is_expected.to respond_to(:modify).with(5).arguments }
it { is_expected.to respond_to(:retrieve).with(6).arguments }
it { is_expected.to respond_to(:revert).with(5).arguments }
it { is_expected.to respond_to(:query).with(3).arguments }
it { is_expected.to respond_to(:snapshot).with(4).arguments }
it { is_expected.to respond_to(:status).with(2).arguments }
it { is_expected.to respond_to(:summary).with(2).arguments }
end
describe Pooler do
subject { Pooler }
it_behaves_like 'a vmfloaty service'
end
describe ABS do
subject { ABS }
it_behaves_like 'a vmfloaty service'
end
describe NonstandardPooler do
subject { NonstandardPooler }
it_behaves_like 'a vmfloaty service'
end