mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Adding spec tests for #list
This commit is contained in:
parent
4df970b21f
commit
cd7c0fae13
2 changed files with 56 additions and 12 deletions
|
|
@ -172,10 +172,10 @@ class ABS
|
||||||
res_body = JSON.parse(res.body)
|
res_body = JSON.parse(res.body)
|
||||||
if res_body.key?('vmpooler_platforms')
|
if res_body.key?('vmpooler_platforms')
|
||||||
os_list << '*** VMPOOLER Pools ***'
|
os_list << '*** VMPOOLER Pools ***'
|
||||||
if res_body['vmpooler_platforms'].is_a?(Hash)
|
if res_body['vmpooler_platforms'].is_a?(String)
|
||||||
os_list += res_body['vmpooler_platforms']
|
|
||||||
else
|
|
||||||
os_list += JSON.parse(res_body['vmpooler_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
|
os_list += JSON.parse(res_body['vmpooler_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
|
||||||
|
else
|
||||||
|
os_list += res_body['vmpooler_platforms']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -186,10 +186,10 @@ class ABS
|
||||||
if res_body.key?('ondemand_vmpooler_platforms') && res_body['ondemand_vmpooler_platforms'] != '[]'
|
if res_body.key?('ondemand_vmpooler_platforms') && res_body['ondemand_vmpooler_platforms'] != '[]'
|
||||||
os_list << ''
|
os_list << ''
|
||||||
os_list << '*** VMPOOLER ONDEMAND Pools ***'
|
os_list << '*** VMPOOLER ONDEMAND Pools ***'
|
||||||
if res_body['ondemand_vmpooler_platforms'].is_a?(Hash)
|
if res_body['ondemand_vmpooler_platforms'].is_a?(String)
|
||||||
os_list += res_body['ondemand_vmpooler_platforms']
|
|
||||||
else
|
|
||||||
os_list += JSON.parse(res_body['ondemand_vmpooler_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
|
os_list += JSON.parse(res_body['ondemand_vmpooler_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
|
||||||
|
else
|
||||||
|
os_list += res_body['ondemand_vmpooler_platforms']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -200,10 +200,10 @@ class ABS
|
||||||
if res_body.key?('nspooler_platforms')
|
if res_body.key?('nspooler_platforms')
|
||||||
os_list << ''
|
os_list << ''
|
||||||
os_list << '*** NSPOOLER Pools ***'
|
os_list << '*** NSPOOLER Pools ***'
|
||||||
if res_body['nspooler_platforms'].is_a?(Hash)
|
if res_body['nspooler_platforms'].is_a?(String)
|
||||||
os_list += res_body['nspooler_platforms']
|
|
||||||
else
|
|
||||||
os_list += JSON.parse(res_body['nspooler_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
|
os_list += JSON.parse(res_body['nspooler_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
|
||||||
|
else
|
||||||
|
os_list += res_body['nspooler_platforms']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -214,10 +214,10 @@ class ABS
|
||||||
if res_body.key?('aws_platforms')
|
if res_body.key?('aws_platforms')
|
||||||
os_list << ''
|
os_list << ''
|
||||||
os_list << '*** AWS Pools ***'
|
os_list << '*** AWS Pools ***'
|
||||||
if res_body['aws_platforms'].is_a?(Hash)
|
if res_body['aws_platforms'].is_a?(String)
|
||||||
os_list += res_body['aws_platforms']
|
|
||||||
else
|
|
||||||
os_list += JSON.parse(res_body['aws_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
|
os_list += JSON.parse(res_body['aws_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
|
||||||
|
else
|
||||||
|
os_list += res_body['aws_platforms']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,50 @@ describe ABS do
|
||||||
before :each do
|
before :each do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#list' do
|
||||||
|
it 'skips empty platforms and lists aws' do
|
||||||
|
stub_request(:get, "http://foo/status/platforms/vmpooler").
|
||||||
|
to_return(:status => 200, :body => "", :headers => {})
|
||||||
|
stub_request(:get, "http://foo/status/platforms/ondemand_vmpooler").
|
||||||
|
to_return(:status => 200, :body => "", :headers => {})
|
||||||
|
stub_request(:get, "http://foo/status/platforms/nspooler").
|
||||||
|
to_return(:status => 200, :body => "", :headers => {})
|
||||||
|
body = '{
|
||||||
|
"aws_platforms": [
|
||||||
|
"amazon-6-x86_64",
|
||||||
|
"amazon-7-x86_64",
|
||||||
|
"amazon-7-arm64",
|
||||||
|
"centos-7-x86-64-west",
|
||||||
|
"redhat-8-arm64"
|
||||||
|
]
|
||||||
|
}'
|
||||||
|
stub_request(:get, "http://foo/status/platforms/aws").
|
||||||
|
to_return(:status => 200, :body => body, :headers => {})
|
||||||
|
|
||||||
|
|
||||||
|
results = ABS.list(false, "http://foo")
|
||||||
|
|
||||||
|
expect(results).to include("amazon-6-x86_64", "amazon-7-x86_64", "amazon-7-arm64", "centos-7-x86-64-west", "redhat-8-arm64")
|
||||||
|
end
|
||||||
|
it 'legacy JSON string, prior to PR 306' do
|
||||||
|
stub_request(:get, "http://foo/status/platforms/vmpooler").
|
||||||
|
to_return(:status => 200, :body => "", :headers => {})
|
||||||
|
stub_request(:get, "http://foo/status/platforms/ondemand_vmpooler").
|
||||||
|
to_return(:status => 200, :body => "", :headers => {})
|
||||||
|
stub_request(:get, "http://foo/status/platforms/nspooler").
|
||||||
|
to_return(:status => 200, :body => "", :headers => {})
|
||||||
|
body = '{
|
||||||
|
"aws_platforms": "[\"amazon-6-x86_64\",\"amazon-7-x86_64\",\"amazon-7-arm64\",\"centos-7-x86-64-west\",\"redhat-8-arm64\"]"
|
||||||
|
}'
|
||||||
|
stub_request(:get, "http://foo/status/platforms/aws").
|
||||||
|
to_return(:status => 200, :body => body, :headers => {})
|
||||||
|
|
||||||
|
results = ABS.list(false, "http://foo")
|
||||||
|
|
||||||
|
expect(results).to include("amazon-6-x86_64", "amazon-7-x86_64", "amazon-7-arm64", "centos-7-x86-64-west", "redhat-8-arm64")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#format' do
|
describe '#format' do
|
||||||
it 'returns an hash formatted like a vmpooler return, plus the job_id' do
|
it 'returns an hash formatted like a vmpooler return, plus the job_id' do
|
||||||
job_id = "generated_by_floaty_12345"
|
job_id = "generated_by_floaty_12345"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue