mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
(rubocop) Style/HashSyntax to use hash_rockets for consistency
This commit is contained in:
parent
42014ae39f
commit
fcf7154a8b
5 changed files with 35 additions and 33 deletions
|
|
@ -4,3 +4,5 @@ AllCops:
|
||||||
|
|
||||||
Style/Documentation:
|
Style/Documentation:
|
||||||
Enabled: False
|
Enabled: False
|
||||||
|
Style/HashSyntax:
|
||||||
|
EnforcedStyle: hash_rockets
|
||||||
|
|
|
||||||
2
Gemfile
2
Gemfile
|
|
@ -4,7 +4,7 @@ source 'https://rubygems.org'
|
||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
gem 'rake', require: false
|
gem 'rake', :require => false
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'rspec', '~> 3.5.0'
|
gem 'rspec', '~> 3.5.0'
|
||||||
|
|
|
||||||
2
Rakefile
2
Rakefile
|
|
@ -28,4 +28,4 @@ RuboCop::RakeTask.new(:rubocop) do |task|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Default task is to run the unit tests
|
# Default task is to run the unit tests
|
||||||
task default: :spec
|
task :default => :spec
|
||||||
|
|
|
||||||
|
|
@ -152,10 +152,10 @@ class Vmfloaty
|
||||||
|
|
||||||
tags = options.tags ? JSON.parse(options.tags) : nil
|
tags = options.tags ? JSON.parse(options.tags) : nil
|
||||||
modify_hash = {
|
modify_hash = {
|
||||||
lifetime: options.lifetime,
|
:lifetime => options.lifetime,
|
||||||
disk: options.disk,
|
:disk => options.disk,
|
||||||
tags: tags,
|
:tags => tags,
|
||||||
reason: options.reason
|
:reason => options.reason
|
||||||
}
|
}
|
||||||
modify_hash.delete_if { |_, value| value.nil? }
|
modify_hash.delete_if { |_, value| value.nil? }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ describe NonstandardPooler do
|
||||||
|
|
||||||
it 'returns an array with operating systems from the pooler' do
|
it 'returns an array with operating systems from the pooler' do
|
||||||
stub_request(:get, "#{@nspooler_url}/status")
|
stub_request(:get, "#{@nspooler_url}/status")
|
||||||
.to_return(status: 200, body: @status_response_body, headers: {})
|
.to_return(:status => 200, :body => @status_response_body, :headers => {})
|
||||||
|
|
||||||
list = NonstandardPooler.list(false, @nspooler_url, nil)
|
list = NonstandardPooler.list(false, @nspooler_url, nil)
|
||||||
expect(list).to be_an_instance_of Array
|
expect(list).to be_an_instance_of Array
|
||||||
|
|
@ -57,7 +57,7 @@ describe NonstandardPooler do
|
||||||
|
|
||||||
it 'filters operating systems based on the filter param' do
|
it 'filters operating systems based on the filter param' do
|
||||||
stub_request(:get, "#{@nspooler_url}/status")
|
stub_request(:get, "#{@nspooler_url}/status")
|
||||||
.to_return(status: 200, body: @status_response_body, headers: {})
|
.to_return(:status => 200, :body => @status_response_body, :headers => {})
|
||||||
|
|
||||||
list = NonstandardPooler.list(false, @nspooler_url, 'aix')
|
list = NonstandardPooler.list(false, @nspooler_url, 'aix')
|
||||||
expect(list).to be_an_instance_of Array
|
expect(list).to be_an_instance_of Array
|
||||||
|
|
@ -66,7 +66,7 @@ describe NonstandardPooler do
|
||||||
|
|
||||||
it 'returns nothing if the filter does not match' do
|
it 'returns nothing if the filter does not match' do
|
||||||
stub_request(:get, "#{@nspooler_url}/status")
|
stub_request(:get, "#{@nspooler_url}/status")
|
||||||
.to_return(status: 199, body: @status_response_body, headers: {})
|
.to_return(:status => 199, :body => @status_response_body, :headers => {})
|
||||||
|
|
||||||
list = NonstandardPooler.list(false, @nspooler_url, 'windows')
|
list = NonstandardPooler.list(false, @nspooler_url, 'windows')
|
||||||
expect(list).to be_an_instance_of Array
|
expect(list).to be_an_instance_of Array
|
||||||
|
|
@ -134,8 +134,8 @@ BODY
|
||||||
|
|
||||||
it 'raises an AuthError if the token is invalid' do
|
it 'raises an AuthError if the token is invalid' do
|
||||||
stub_request(:post, "#{@nspooler_url}/host/solaris-11-sparc")
|
stub_request(:post, "#{@nspooler_url}/host/solaris-11-sparc")
|
||||||
.with(headers: @post_request_headers)
|
.with(:headers => @post_request_headers)
|
||||||
.to_return(status: 401, body: '{"ok":false,"reason": "token: token-value does not exist"}', headers: {})
|
.to_return(:status => 401, :body => '{"ok":false,"reason": "token: token-value does not exist"}', :headers => {})
|
||||||
|
|
||||||
vm_hash = { 'solaris-11-sparc' => 1 }
|
vm_hash = { 'solaris-11-sparc' => 1 }
|
||||||
expect { NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url) }.to raise_error(AuthError)
|
expect { NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url) }.to raise_error(AuthError)
|
||||||
|
|
@ -143,8 +143,8 @@ BODY
|
||||||
|
|
||||||
it 'retrieves a single vm with a token' do
|
it 'retrieves a single vm with a token' do
|
||||||
stub_request(:post, "#{@nspooler_url}/host/solaris-11-sparc")
|
stub_request(:post, "#{@nspooler_url}/host/solaris-11-sparc")
|
||||||
.with(headers: @post_request_headers)
|
.with(:headers => @post_request_headers)
|
||||||
.to_return(status: 200, body: @retrieve_response_body_single, headers: {})
|
.to_return(:status => 200, :body => @retrieve_response_body_single, :headers => {})
|
||||||
|
|
||||||
vm_hash = { 'solaris-11-sparc' => 1 }
|
vm_hash = { 'solaris-11-sparc' => 1 }
|
||||||
vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url)
|
vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url)
|
||||||
|
|
@ -155,8 +155,8 @@ BODY
|
||||||
|
|
||||||
it 'retrieves a multiple vms with a token' do
|
it 'retrieves a multiple vms with a token' do
|
||||||
stub_request(:post,"#{@nspooler_url}/host/aix-7.1-power+solaris-10-sparc+solaris-10-sparc")
|
stub_request(:post,"#{@nspooler_url}/host/aix-7.1-power+solaris-10-sparc+solaris-10-sparc")
|
||||||
.with(headers: @post_request_headers)
|
.with(:headers => @post_request_headers)
|
||||||
.to_return(status: 200, body: @retrieve_response_body_many, headers: {})
|
.to_return(:status => 200, :body => @retrieve_response_body_many, :headers => {})
|
||||||
|
|
||||||
vm_hash = { 'aix-7.1-power' => 1, 'solaris-10-sparc' => 2 }
|
vm_hash = { 'aix-7.1-power' => 1, 'solaris-10-sparc' => 2 }
|
||||||
vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url)
|
vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url)
|
||||||
|
|
@ -175,10 +175,10 @@ BODY
|
||||||
|
|
||||||
it 'raises an error if the user tries to modify an unsupported attribute' do
|
it 'raises an error if the user tries to modify an unsupported attribute' do
|
||||||
stub_request(:put, 'https://nspooler.example.com/host/myfakehost').
|
stub_request(:put, 'https://nspooler.example.com/host/myfakehost').
|
||||||
with(body: {'{}'=>true},
|
with(:body => {'{}'=>true},
|
||||||
headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'token-value'}).
|
:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'token-value'}).
|
||||||
to_return(status: 200, body: '', headers: {})
|
to_return(:status => 200, :body => '', :headers => {})
|
||||||
details = { lifetime: 12 }
|
details = { :lifetime => 12 }
|
||||||
expect { NonstandardPooler.modify(false, @nspooler_url, 'myfakehost', 'token-value', details) }
|
expect { NonstandardPooler.modify(false, @nspooler_url, 'myfakehost', 'token-value', details) }
|
||||||
.to raise_error(ModifyError)
|
.to raise_error(ModifyError)
|
||||||
end
|
end
|
||||||
|
|
@ -186,11 +186,11 @@ BODY
|
||||||
it 'modifies the reason of a vm' do
|
it 'modifies the reason of a vm' do
|
||||||
modify_request_body = { '{"reserved_for_reason":"testing"}' => true }
|
modify_request_body = { '{"reserved_for_reason":"testing"}' => true }
|
||||||
stub_request(:put, "#{@nspooler_url}/host/myfakehost")
|
stub_request(:put, "#{@nspooler_url}/host/myfakehost")
|
||||||
.with(body: modify_request_body,
|
.with(:body => modify_request_body,
|
||||||
headers: @post_request_headers)
|
:headers => @post_request_headers)
|
||||||
.to_return(status: 200, body: '{"ok": true}', headers: {})
|
.to_return(:status => 200, :body => '{"ok": true}', :headers => {})
|
||||||
|
|
||||||
modify_hash = { reason: 'testing' }
|
modify_hash = { :reason => 'testing' }
|
||||||
modify_req = NonstandardPooler.modify(false, @nspooler_url, 'myfakehost', 'token-value', modify_hash)
|
modify_req = NonstandardPooler.modify(false, @nspooler_url, 'myfakehost', 'token-value', modify_hash)
|
||||||
expect(modify_req['ok']).to be true
|
expect(modify_req['ok']).to be true
|
||||||
end
|
end
|
||||||
|
|
@ -221,8 +221,8 @@ BODY
|
||||||
|
|
||||||
it 'prints the status' do
|
it 'prints the status' do
|
||||||
stub_request(:get, "#{@nspooler_url}/status")
|
stub_request(:get, "#{@nspooler_url}/status")
|
||||||
.with(headers: @get_request_headers)
|
.with(:headers => @get_request_headers)
|
||||||
.to_return(status: 200, body: @status_response_body, headers: {})
|
.to_return(:status => 200, :body => @status_response_body, :headers => {})
|
||||||
|
|
||||||
status = NonstandardPooler.status(false, @nspooler_url)
|
status = NonstandardPooler.status(false, @nspooler_url)
|
||||||
expect(status).to be_an_instance_of Hash
|
expect(status).to be_an_instance_of Hash
|
||||||
|
|
@ -245,8 +245,8 @@ BODY
|
||||||
|
|
||||||
it 'prints the summary' do
|
it 'prints the summary' do
|
||||||
stub_request(:get, "#{@nspooler_url}/summary")
|
stub_request(:get, "#{@nspooler_url}/summary")
|
||||||
.with(headers: @get_request_headers)
|
.with(:headers => @get_request_headers)
|
||||||
.to_return(status: 200, body: @status_response_body, headers: {})
|
.to_return(:status => 200, :body => @status_response_body, :headers => {})
|
||||||
|
|
||||||
summary = NonstandardPooler.summary(false, @nspooler_url)
|
summary = NonstandardPooler.summary(false, @nspooler_url)
|
||||||
expect(summary).to be_an_instance_of Hash
|
expect(summary).to be_an_instance_of Hash
|
||||||
|
|
@ -271,8 +271,8 @@ BODY
|
||||||
|
|
||||||
it 'makes a query about a vm' do
|
it 'makes a query about a vm' do
|
||||||
stub_request(:get, "#{@nspooler_url}/host/sol10-11")
|
stub_request(:get, "#{@nspooler_url}/host/sol10-11")
|
||||||
.with(headers: @get_request_headers_notoken)
|
.with(:headers => @get_request_headers_notoken)
|
||||||
.to_return(status: 200, body: @query_response_body, headers: {})
|
.to_return(:status => 200, :body => @query_response_body, :headers => {})
|
||||||
|
|
||||||
query_req = NonstandardPooler.query(false, @nspooler_url, 'sol10-11')
|
query_req = NonstandardPooler.query(false, @nspooler_url, 'sol10-11')
|
||||||
expect(query_req).to be_an_instance_of Hash
|
expect(query_req).to be_an_instance_of Hash
|
||||||
|
|
@ -287,8 +287,8 @@ BODY
|
||||||
|
|
||||||
it 'deletes a single existing vm' do
|
it 'deletes a single existing vm' do
|
||||||
stub_request(:delete, "#{@nspooler_url}/host/sol11-7")
|
stub_request(:delete, "#{@nspooler_url}/host/sol11-7")
|
||||||
.with(headers: @post_request_headers)
|
.with(:headers => @post_request_headers)
|
||||||
.to_return(status: 200, body: @delete_response_success, 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')
|
||||||
expect(request['sol11-7']['ok']).to be true
|
expect(request['sol11-7']['ok']).to be true
|
||||||
|
|
@ -296,8 +296,8 @@ BODY
|
||||||
|
|
||||||
it 'does not delete a nonexistant vm' do
|
it 'does not delete a nonexistant vm' do
|
||||||
stub_request(:delete, "#{@nspooler_url}/host/fakehost")
|
stub_request(:delete, "#{@nspooler_url}/host/fakehost")
|
||||||
.with(headers: @post_request_headers)
|
.with(:headers => @post_request_headers)
|
||||||
.to_return(status: 401, body: @delete_response_failure, 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')
|
||||||
expect(request['fakehost']['ok']).to be false
|
expect(request['fakehost']['ok']).to be false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue