1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[openstack|compute] update volume tests

This commit is contained in:
Brian D. Burns 2013-08-13 04:57:36 +00:00
parent 0dc399f3a8
commit 587dcbe609
2 changed files with 18 additions and 19 deletions

View file

@ -33,15 +33,16 @@ module Fog
response.status = 202 response.status = 202
data = { data = {
'id' => Fog::Mock.random_numbers(2), 'id' => Fog::Mock.random_numbers(2),
'name' => name, 'displayName' => name,
'description' => description, 'displayDescription' => description,
'size' => size, 'size' => size,
'status' => 'creating', 'status' => 'creating',
'snapshot_id' => '4', 'snapshotId' => nil,
'volume_type' => nil, 'volumeType' => 'None',
'availability_zone' => 'nova', 'availabilityZone' => 'nova',
'created_at' => Time.now, 'createdAt' => Time.now.strftime('%FT%T.%6N'),
'attachments' => [] 'attachments' => [],
'metadata' => {}
} }
self.data[:volumes][data['id']] = data self.data[:volumes][data['id']] = data
response.body = { 'volume' => data } response.body = { 'volume' => data }

View file

@ -4,35 +4,33 @@ Shindo.tests('Fog::Compute[:openstack] | volume requests', ['openstack']) do
@volume_format = { @volume_format = {
'id' => String, 'id' => String,
'name' => String, 'displayName' => String,
'size' => Integer, 'size' => Integer,
'description' => String, 'displayDescription' => String,
'status' => String, 'status' => String,
'snapshot_id' => Fog::Nullable::String, 'snapshotId' => Fog::Nullable::String,
'availability_zone' => String, 'availabilityZone' => String,
'attachments' => Array, 'attachments' => Array,
'volume_type' => Fog::Nullable::String, 'volumeType' => Fog::Nullable::String,
'created_at' => Time 'createdAt' => String,
'metadata' => Hash
} }
tests('success') do tests('success') do
tests('#create_volume').formats({'volume' => @volume_format}) do tests('#create_volume').data_matches_schema({'volume' => @volume_format}) do
pending unless Fog.mocking?
Fog::Compute[:openstack].create_volume('loud', 'this is a loud volume', 3).body Fog::Compute[:openstack].create_volume('loud', 'this is a loud volume', 3).body
end end
tests('#list_volumes').formats({'volumes' => [@volume_format]}) do tests('#list_volumes').data_matches_schema({'volumes' => [@volume_format]}) do
Fog::Compute[:openstack].list_volumes.body Fog::Compute[:openstack].list_volumes.body
end end
tests('#get_volume_detail').formats({'volume' => @volume_format}) do tests('#get_volume_detail').data_matches_schema({'volume' => @volume_format}) do
pending unless Fog.mocking?
volume_id = Fog::Compute[:openstack].volumes.all.first.id volume_id = Fog::Compute[:openstack].volumes.all.first.id
Fog::Compute[:openstack].get_volume_details(volume_id).body Fog::Compute[:openstack].get_volume_details(volume_id).body
end end
tests('#delete_volume').succeeds do tests('#delete_volume').succeeds do
pending unless Fog.mocking?
volume_id = Fog::Compute[:openstack].volumes.all.first.id volume_id = Fog::Compute[:openstack].volumes.all.first.id
Fog::Compute[:openstack].delete_volume(volume_id) Fog::Compute[:openstack].delete_volume(volume_id)
end end