mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add tests for images.
This commit is contained in:
parent
4a455743ea
commit
f9c289a95b
1 changed files with 75 additions and 0 deletions
75
tests/hp/requests/compute/image_tests.rb
Normal file
75
tests/hp/requests/compute/image_tests.rb
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
Shindo.tests('Fog::Compute[:hp] | image requests', ['hp']) do
|
||||||
|
|
||||||
|
@image_format = {
|
||||||
|
'id' => String,
|
||||||
|
'links' => Array,
|
||||||
|
'metadata' => Fog::Nullable::Hash,
|
||||||
|
'name' => String,
|
||||||
|
'progress' => Fog::Nullable::Integer,
|
||||||
|
'status' => String,
|
||||||
|
'created' => Fog::Nullable::String,
|
||||||
|
'updated' => Fog::Nullable::String
|
||||||
|
}
|
||||||
|
|
||||||
|
@list_images_format = {
|
||||||
|
'id' => String,
|
||||||
|
'name' => String
|
||||||
|
}
|
||||||
|
|
||||||
|
tests('success') do
|
||||||
|
@server_name = "fogservertest"
|
||||||
|
@image_name = "fogimagetest"
|
||||||
|
@server = Fog::Compute[:hp].servers.create(:name => @server_name, :flavor_id => 100, :image_id => 1242)
|
||||||
|
@server.wait_for { ready? }
|
||||||
|
@image_id = nil
|
||||||
|
|
||||||
|
tests("#create_image(#{@server.id}, #{@image_name})").formats({}) do
|
||||||
|
response = Fog::Compute[:hp].create_image(@server.id, @image_name)
|
||||||
|
# no data is returned for the call, so get id off the header
|
||||||
|
@image_id = response.headers["Location"].split("/")[5]
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
|
||||||
|
unless Fog.mocking?
|
||||||
|
Fog::Compute[:hp].images.get(@image_id).wait_for { ready? }
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#get_image_details(#{@image_id})").formats(@image_format) do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
Fog::Compute[:hp].get_image_details(@image_id).body['image']
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#list_images').formats({'images' => [@list_images_format]}) do
|
||||||
|
Fog::Compute[:hp].list_images.body
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#list_images_detail').formats({'images' => [@image_format]}) do
|
||||||
|
Fog::Compute[:hp].list_images_detail.body
|
||||||
|
end
|
||||||
|
|
||||||
|
unless Fog.mocking?
|
||||||
|
Fog::Compute[:hp].images.get(@image_id).wait_for { ready? }
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#delete_image(#{@image_id})").succeeds do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
Fog::Compute[:hp].delete_image(@image_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
@server.destroy
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('failure') do
|
||||||
|
|
||||||
|
tests('#delete_image(0)').raises(Excon::Errors::BadRequest) do
|
||||||
|
Fog::Compute[:hp].delete_image(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#get_image_details(0)').raises(Fog::Compute::HP::NotFound) do
|
||||||
|
Fog::Compute[:hp].get_image_details(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue