mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Beginnings of shin do request tests.
This commit is contained in:
parent
a809a07178
commit
30520ae493
3 changed files with 31 additions and 69 deletions
|
@ -12,7 +12,7 @@ def array_differences(array_a, array_b)
|
|||
end
|
||||
|
||||
# check to see which credentials are available and add others to the skipped tags list
|
||||
all_providers = ['aws', 'bluebox', 'brightbox', 'dnsimple', 'dnsmadeeasy', 'dynect', 'ecloud', 'glesys', 'gogrid', 'google', 'hp', 'linode', 'local', 'ninefold', 'newservers', 'openstack', 'rackspace', 'slicehost', 'stormondemand', 'voxel', 'zerigo']
|
||||
all_providers = ['aws', 'bluebox', 'brightbox', 'dnsimple', 'dnsmadeeasy', 'dynect', 'ecloud', 'glesys', 'gogrid', 'google', 'hp', 'linode', 'local', 'ninefold', 'newservers', 'openstack', 'rackspace', 'serverlove' 'slicehost', 'stormondemand', 'voxel', 'zerigo']
|
||||
available_providers = Fog.available_providers.map {|provider| provider.downcase}
|
||||
for provider in (all_providers - available_providers)
|
||||
Formatador.display_line("[yellow]Skipping tests for [bold]#{provider}[/] [yellow]due to lacking credentials (add some to '~/.fog' to run them)[/]")
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
Shindo.tests('Fog::Compute[:serverlove] | drive requests', ['serverlove']) do
|
||||
|
||||
@image_format = {
|
||||
'created' => Fog::Nullable::String,
|
||||
'id' => Integer,
|
||||
'name' => String,
|
||||
'progress' => Fog::Nullable::Integer,
|
||||
'serverId' => Fog::Nullable::Integer,
|
||||
'status' => String,
|
||||
'updated' => String
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
|
||||
@server = Fog::Compute[:serverlove].servers.create(:flavor_id => 1, :image_id => 19)
|
||||
@server.wait_for { ready? }
|
||||
@image_id = nil
|
||||
|
||||
tests("#create_image(#{@server.id})").formats(@image_format) do
|
||||
data = Fog::Compute[:serverlove].create_image(@server.id).body['image']
|
||||
@image_id = data['id']
|
||||
data
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
Fog::Compute[:serverlove].images.get(@image_id).wait_for { ready? }
|
||||
end
|
||||
|
||||
tests("#get_image_details(#{@image_id})").formats(@image_format) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:serverlove].get_image_details(@image_id).body['image']
|
||||
end
|
||||
|
||||
tests('#list_images').formats({'images' => [serverlove::Compute::Formats::SUMMARY]}) do
|
||||
Fog::Compute[:serverlove].list_images.body
|
||||
end
|
||||
|
||||
tests('#list_images_detail').formats({'images' => [@image_format]}) do
|
||||
Fog::Compute[:serverlove].list_images_detail.body
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
Fog::Compute[:serverlove].images.get(@image_id).wait_for { ready? }
|
||||
end
|
||||
|
||||
tests("#delete_image(#{@image_id})").succeeds do
|
||||
pending if Fog.mocking? # because it will fail without the wait just above here, which won't work
|
||||
Fog::Compute[:serverlove].delete_image(@image_id)
|
||||
end
|
||||
|
||||
@server.destroy
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests('#delete_image(0)').raises(Excon::Errors::BadRequest) do
|
||||
Fog::Compute[:serverlove].delete_image(0)
|
||||
end
|
||||
|
||||
tests('#get_image_details(0)').raises(Fog::Compute::serverlove::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:serverlove].get_image_details(0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
30
tests/serverlove/requests/compute/image_tests.rb
Normal file
30
tests/serverlove/requests/compute/image_tests.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
Shindo.tests('Fog::Compute[:serverlove] | drive requests', ['serverlove']) do
|
||||
|
||||
@image_format = {
|
||||
'id' => String,
|
||||
'name' => String,
|
||||
'user' => String,
|
||||
'size' => Integer,
|
||||
'claimed' => Fog::Nullable::String
|
||||
'status' => String,
|
||||
'encryption_cipher' => String
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
|
||||
attributes = { name: 'Test', size: 12345 }
|
||||
|
||||
tests("#create_image").formats(@image_format) do
|
||||
@image = Fog::Compute[:serverlove].create(attributes)
|
||||
@image
|
||||
end
|
||||
|
||||
tests('#list_images_detail').formats({'images' => [@image_format]}) do
|
||||
Fog::Compute[:serverlove].images
|
||||
end
|
||||
|
||||
@image.destroy
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue