mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
(rubocop) Fix Style/StringLiterals
This commit is contained in:
parent
cf2295ccfd
commit
1272343cdd
12 changed files with 181 additions and 181 deletions
|
|
@ -3,15 +3,15 @@ require_relative '../../lib/vmfloaty/pooler'
|
|||
|
||||
describe Pooler do
|
||||
before :each do
|
||||
@vmpooler_url = "https://vmpooler.example.com"
|
||||
@vmpooler_url = 'https://vmpooler.example.com'
|
||||
end
|
||||
|
||||
describe "#list" do
|
||||
describe '#list' do
|
||||
before :each do
|
||||
@list_response_body = "[\"debian-7-i386\",\"debian-7-x86_64\",\"centos-7-x86_64\"]"
|
||||
@list_response_body = '["debian-7-i386","debian-7-x86_64","centos-7-x86_64"]'
|
||||
end
|
||||
|
||||
it "returns a hash with operating systems from the pooler" do
|
||||
it 'returns a hash with operating systems from the pooler' do
|
||||
stub_request(:get, "#{@vmpooler_url}/vm").
|
||||
to_return(:status => 200, :body => @list_response_body, :headers => {})
|
||||
|
||||
|
|
@ -19,42 +19,42 @@ describe Pooler do
|
|||
expect(list).to be_an_instance_of Array
|
||||
end
|
||||
|
||||
it "filters operating systems based on the filter param" do
|
||||
it 'filters operating systems based on the filter param' do
|
||||
stub_request(:get, "#{@vmpooler_url}/vm").
|
||||
to_return(:status => 200, :body => @list_response_body, :headers => {})
|
||||
|
||||
list = Pooler.list(false, @vmpooler_url, "deb")
|
||||
list = Pooler.list(false, @vmpooler_url, 'deb')
|
||||
expect(list).to be_an_instance_of Array
|
||||
expect(list.size).to equal 2
|
||||
end
|
||||
|
||||
it "returns nothing if the filter does not match" do
|
||||
it 'returns nothing if the filter does not match' do
|
||||
stub_request(:get, "#{@vmpooler_url}/vm").
|
||||
to_return(:status => 200, :body => @list_response_body, :headers => {})
|
||||
|
||||
list = Pooler.list(false, @vmpooler_url, "windows")
|
||||
list = Pooler.list(false, @vmpooler_url, 'windows')
|
||||
expect(list).to be_an_instance_of Array
|
||||
expect(list.size).to equal 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "#retrieve" do
|
||||
describe '#retrieve' do
|
||||
before :each do
|
||||
@retrieve_response_body_single = "{\"ok\":true,\"debian-7-i386\":{\"hostname\":\"fq6qlpjlsskycq6\"}}"
|
||||
@retrieve_response_body_double = "{\"ok\":true,\"debian-7-i386\":{\"hostname\":[\"sc0o4xqtodlul5w\",\"4m4dkhqiufnjmxy\"]},\"centos-7-x86_64\":{\"hostname\":\"zb91y9qbrbf6d3q\"}}"
|
||||
@retrieve_response_body_single = '{"ok":true,"debian-7-i386":{"hostname":"fq6qlpjlsskycq6"}}'
|
||||
@retrieve_response_body_double = '{"ok":true,"debian-7-i386":{"hostname":["sc0o4xqtodlul5w","4m4dkhqiufnjmxy"]},"centos-7-x86_64":{"hostname":"zb91y9qbrbf6d3q"}}'
|
||||
end
|
||||
|
||||
it "raises an AuthError if the token is invalid" do
|
||||
it 'raises an AuthError if the token is invalid' do
|
||||
stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386").
|
||||
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
|
||||
to_return(:status => 401, :body => "{\"ok\":false}", :headers => {})
|
||||
to_return(:status => 401, :body => '{"ok":false}', :headers => {})
|
||||
|
||||
vm_hash = {}
|
||||
vm_hash['debian-7-i386'] = 1
|
||||
expect{ Pooler.retrieve(false, vm_hash, 'mytokenfile', @vmpooler_url) }.to raise_error(AuthError)
|
||||
end
|
||||
|
||||
it "retrieves a single vm with a token" do
|
||||
it 'retrieves a single vm with a token' do
|
||||
stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386").
|
||||
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
|
||||
to_return(:status => 200, :body => @retrieve_response_body_single, :headers => {})
|
||||
|
|
@ -63,11 +63,11 @@ describe Pooler do
|
|||
vm_hash['debian-7-i386'] = 1
|
||||
vm_req = Pooler.retrieve(false, vm_hash, 'mytokenfile', @vmpooler_url)
|
||||
expect(vm_req).to be_an_instance_of Hash
|
||||
expect(vm_req["ok"]).to equal true
|
||||
expect(vm_req["debian-7-i386"]["hostname"]).to eq "fq6qlpjlsskycq6"
|
||||
expect(vm_req['ok']).to equal true
|
||||
expect(vm_req['debian-7-i386']['hostname']).to eq 'fq6qlpjlsskycq6'
|
||||
end
|
||||
|
||||
it "retrieves a multiple vms with a token" do
|
||||
it 'retrieves a multiple vms with a token' do
|
||||
stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386+debian-7-i386+centos-7-x86_64").
|
||||
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
|
||||
to_return(:status => 200, :body => @retrieve_response_body_double, :headers => {})
|
||||
|
|
@ -77,24 +77,24 @@ describe Pooler do
|
|||
vm_hash['centos-7-x86_64'] = 1
|
||||
vm_req = Pooler.retrieve(false, vm_hash, 'mytokenfile', @vmpooler_url)
|
||||
expect(vm_req).to be_an_instance_of Hash
|
||||
expect(vm_req["ok"]).to equal true
|
||||
expect(vm_req["debian-7-i386"]["hostname"]).to be_an_instance_of Array
|
||||
expect(vm_req["debian-7-i386"]["hostname"]).to eq ["sc0o4xqtodlul5w", "4m4dkhqiufnjmxy"]
|
||||
expect(vm_req["centos-7-x86_64"]["hostname"]).to eq "zb91y9qbrbf6d3q"
|
||||
expect(vm_req['ok']).to equal true
|
||||
expect(vm_req['debian-7-i386']['hostname']).to be_an_instance_of Array
|
||||
expect(vm_req['debian-7-i386']['hostname']).to eq ['sc0o4xqtodlul5w', '4m4dkhqiufnjmxy']
|
||||
expect(vm_req['centos-7-x86_64']['hostname']).to eq 'zb91y9qbrbf6d3q'
|
||||
end
|
||||
end
|
||||
|
||||
describe "#modify" do
|
||||
describe '#modify' do
|
||||
before :each do
|
||||
@modify_response_body_success = "{\"ok\":true}"
|
||||
@modify_response_body_fail = "{\"ok\":false}"
|
||||
@modify_response_body_success = '{"ok":true}'
|
||||
@modify_response_body_fail = '{"ok":false}'
|
||||
end
|
||||
|
||||
it "raises a TokenError if token provided is nil" do
|
||||
it 'raises a TokenError if token provided is nil' do
|
||||
expect{ Pooler.modify(false, @vmpooler_url, 'myfakehost', nil, {}) }.to raise_error(TokenError)
|
||||
end
|
||||
|
||||
it "modifies the TTL of a vm" do
|
||||
it 'modifies the TTL of a vm' do
|
||||
modify_hash = { :lifetime => 12 }
|
||||
stub_request(:put, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6").
|
||||
with(:body => {'{"lifetime":12}'=>true},
|
||||
|
|
@ -102,17 +102,17 @@ describe Pooler do
|
|||
to_return(:status => 200, :body => @modify_response_body_success, :headers => {})
|
||||
|
||||
modify_req = Pooler.modify(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', modify_hash)
|
||||
expect(modify_req["ok"]).to be true
|
||||
expect(modify_req['ok']).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#delete" do
|
||||
describe '#delete' do
|
||||
before :each do
|
||||
@delete_response_body_success = "{\"ok\":true}"
|
||||
@delete_response = {"fq6qlpjlsskycq6"=>{"ok"=>true}}
|
||||
@delete_response_body_success = '{"ok":true}'
|
||||
@delete_response = {'fq6qlpjlsskycq6'=>{'ok'=>true}}
|
||||
end
|
||||
|
||||
it "deletes a specified vm" do
|
||||
it 'deletes a specified vm' do
|
||||
stub_request(:delete, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6").
|
||||
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
|
||||
to_return(:status => 200, :body => @delete_response_body_success, :headers => {})
|
||||
|
|
@ -120,18 +120,18 @@ describe Pooler do
|
|||
expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile')).to eq @delete_response
|
||||
end
|
||||
|
||||
it "raises a token error if no token provided" do
|
||||
it 'raises a token error if no token provided' do
|
||||
expect{ Pooler.delete(false, @vmpooler_url, ['myfakehost'], nil) }.to raise_error(TokenError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#status" do
|
||||
describe '#status' do
|
||||
before :each do
|
||||
#smaller version
|
||||
@status_response_body = "{\"capacity\":{\"current\":716,\"total\":717,\"percent\": 99.9},\"status\":{\"ok\":true,\"message\":\"Battle station fully armed and operational.\"}}"
|
||||
@status_response_body = '{"capacity":{"current":716,"total":717,"percent": 99.9},"status":{"ok":true,"message":"Battle station fully armed and operational."}}'
|
||||
end
|
||||
|
||||
it "prints the status" do
|
||||
it 'prints the status' do
|
||||
stub_request(:get, "#{@vmpooler_url}/status").
|
||||
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.2'}).
|
||||
to_return(:status => 200, :body => @status_response_body, :headers => {})
|
||||
|
|
@ -141,21 +141,21 @@ describe Pooler do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#summary" do
|
||||
describe '#summary' do
|
||||
before :each do
|
||||
@status_response_body = ""
|
||||
@status_response_body = ''
|
||||
|
||||
it "prints the summary" do
|
||||
it 'prints the summary' do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#query" do
|
||||
describe '#query' do
|
||||
before :each do
|
||||
@query_response_body = "{\"ok\": true,\"fq6qlpjlsskycq6\":{\"template\":\"debian-7-x86_64\",\"lifetime\": 2,\"running\": 0.08,\"state\":\"running\",\"snapshots\":[\"n4eb4kdtp7rwv4x158366vd9jhac8btq\" ],\"domain\": \"delivery.puppetlabs.net\"}}"
|
||||
@query_response_body = '{"ok": true,"fq6qlpjlsskycq6":{"template":"debian-7-x86_64","lifetime": 2,"running": 0.08,"state":"running","snapshots":["n4eb4kdtp7rwv4x158366vd9jhac8btq" ],"domain": "delivery.puppetlabs.net"}}'
|
||||
end
|
||||
|
||||
it "makes a query about a vm" do
|
||||
it 'makes a query about a vm' do
|
||||
stub_request(:get, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6").
|
||||
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.2'}).
|
||||
to_return(:status => 200, :body => @query_response_body, :headers => {})
|
||||
|
|
@ -165,59 +165,59 @@ describe Pooler do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#snapshot" do
|
||||
describe '#snapshot' do
|
||||
before :each do
|
||||
@snapshot_response_body = "{\"ok\":true}"
|
||||
@snapshot_response_body = '{"ok":true}'
|
||||
end
|
||||
|
||||
it "makes a snapshot for a single vm" do
|
||||
it 'makes a snapshot for a single vm' do
|
||||
stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/snapshot").
|
||||
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
|
||||
to_return(:status => 200, :body => @snapshot_response_body, :headers => {})
|
||||
|
||||
snapshot_req = Pooler.snapshot(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile')
|
||||
expect(snapshot_req["ok"]).to be true
|
||||
expect(snapshot_req['ok']).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#revert" do
|
||||
describe '#revert' do
|
||||
before :each do
|
||||
@revert_response_body = "{\"ok\":true}"
|
||||
@revert_response_body = '{"ok":true}'
|
||||
end
|
||||
|
||||
it "makes a request to revert a vm from a snapshot" do
|
||||
it 'makes a request to revert a vm from a snapshot' do
|
||||
stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/snapshot/dAfewKNfaweLKNve").
|
||||
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
|
||||
to_return(:status => 200, :body => @revert_response_body, :headers => {})
|
||||
|
||||
revert_req = Pooler.revert(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', 'dAfewKNfaweLKNve')
|
||||
expect(revert_req["ok"]).to be true
|
||||
expect(revert_req['ok']).to be true
|
||||
end
|
||||
|
||||
it "doesn't make a request to revert a vm if snapshot is not provided" do
|
||||
expect{ Pooler.revert(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', nil) }.to raise_error(RuntimeError, "Snapshot SHA provided was nil, could not revert fq6qlpjlsskycq6")
|
||||
expect{ Pooler.revert(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', nil) }.to raise_error(RuntimeError, 'Snapshot SHA provided was nil, could not revert fq6qlpjlsskycq6')
|
||||
end
|
||||
|
||||
it "raises a TokenError if no token was provided" do
|
||||
it 'raises a TokenError if no token was provided' do
|
||||
expect{ Pooler.revert(false, @vmpooler_url, 'myfakehost', nil, 'shaaaaaaa') }.to raise_error(TokenError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#disk" do
|
||||
describe '#disk' do
|
||||
before :each do
|
||||
@disk_response_body_success = "{\"ok\":true}"
|
||||
@disk_response_body_fail = "{\"ok\":false}"
|
||||
@disk_response_body_success = '{"ok":true}'
|
||||
@disk_response_body_fail = '{"ok":false}'
|
||||
end
|
||||
|
||||
it "makes a request to extend disk space of a vm" do
|
||||
it 'makes a request to extend disk space of a vm' do
|
||||
stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/disk/12").
|
||||
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}). to_return(:status => 200, :body => @disk_response_body_success, :headers => {})
|
||||
|
||||
disk_req = Pooler.disk(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', 12)
|
||||
expect(disk_req["ok"]).to be true
|
||||
expect(disk_req['ok']).to be true
|
||||
end
|
||||
|
||||
it "raises a TokenError if no token was provided" do
|
||||
it 'raises a TokenError if no token was provided' do
|
||||
expect{ Pooler.disk(false, @vmpooler_url, 'myfakehost', nil, 12) }.to raise_error(TokenError)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue