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

[ibm] Update mocks to reflect moving volume models from from compute to storage

This commit is contained in:
Decklin Foster 2012-02-13 09:59:12 -05:00
parent 02fc7a2232
commit 5e679a641e
5 changed files with 40 additions and 18 deletions

View file

@ -89,7 +89,6 @@ module Fog
:keys => {}, :keys => {},
:locations => populate_locations, :locations => populate_locations,
:private_keys => {}, :private_keys => {},
:volumes => {},
:addresses => {} :addresses => {}
} }
end end

View file

@ -48,7 +48,7 @@ module Fog
response.status = 404 response.status = 404
end end
elsif params['type'] == 'attach' || params['type'] == 'detach' elsif params['type'] == 'attach' || params['type'] == 'detach'
if (instance_exists?(instance_id) && volume_exists?(volume_id)) if (instance_exists?(instance_id) && Fog::Storage[:ibm].volume_exists?(volume_id))
# TODO: Update the instance in the data hash, assuming IBM ever gets this feature working properly. # TODO: Update the instance in the data hash, assuming IBM ever gets this feature working properly.
response.status = 415 response.status = 415
else else

View file

@ -48,8 +48,31 @@ module Fog
class Mock class Mock
def request(options) def self.data
Fog::Mock.not_implemented @data ||= Hash.new do |hash, key|
hash[key] = {
:volumes => {},
}
end
end
def self.reset
@data = nil
end
def data
self.class.data[@ibm_user_id]
end
def reset_data
self.class.data.delete(@ibm_user_id)
@data = self.class.data[@ibm_user_id]
end
def initialize(options={})
@ibm_user_id = options[:ibm_user_id]
@ibm_password = options[:ibm_password]
@data = self.class.data[@ibm_user_id]
end end
end end

View file

@ -1,4 +1,4 @@
Shindo.tests('Fog::Compute[:ibm] | volume', ['ibm']) do Shindo.tests('Fog::Storage[:ibm] | volume', ['ibm']) do
tests('success') do tests('success') do
@ -10,8 +10,8 @@ Shindo.tests('Fog::Compute[:ibm] | volume', ['ibm']) do
@size = "256" @size = "256"
@offering_id = "20001208" @offering_id = "20001208"
tests('Fog::Compute::IBM::Volume.new') do tests('Fog::Storage::IBM::Volume.new') do
@volume = Fog::Compute[:ibm].volumes.new( @volume = Fog::Storage[:ibm].volumes.new(
:name => @name, :name => @name,
:format => @image_id, :format => @image_id,
:location_id => @location_id, :location_id => @location_id,
@ -21,36 +21,36 @@ Shindo.tests('Fog::Compute[:ibm] | volume', ['ibm']) do
returns(@name) { @volume.name } returns(@name) { @volume.name }
end end
tests('Fog::Compute::IBM::Volume#save') do tests('Fog::Storage::IBM::Volume#save') do
returns(true) { @volume.save } returns(true) { @volume.save }
returns(String) { @volume.id.class } returns(String) { @volume.id.class }
@volume_id = @volume.id @volume_id = @volume.id
end end
tests("Fog::Compute::IBM::Volume#instance") do tests("Fog::Storage::IBM::Volume#instance") do
returns(nil) { @volume.instance } returns(nil) { @volume.instance }
end end
tests("Fog::Compute::IBM::Volume#location") do tests("Fog::Storage::IBM::Volume#location") do
returns(Fog::Compute::IBM::Location) { @volume.location.class } returns(Fog::Compute::IBM::Location) { @volume.location.class }
end end
tests('Fog::Compute::IBM::Volume#id') do tests('Fog::Storage::IBM::Volume#id') do
returns(@volume_id) { @volume.id } returns(@volume_id) { @volume.id }
end end
tests('Fog::Compute::IBM::Volume#ready?') do tests('Fog::Storage::IBM::Volume#ready?') do
# We do a "get" to advance the state if we are mocked. # We do a "get" to advance the state if we are mocked.
# TODO: Fix this for real connections # TODO: Fix this for real connections
Fog::Compute[:ibm].get_volume(@volume_id) Fog::Storage[:ibm].get_volume(@volume_id)
returns(true) { @volume.ready? } returns(true) { @volume.ready? }
end end
tests('Fog::Compute::IBM::Volume#status') do tests('Fog::Storage::IBM::Volume#status') do
returns("Detached") { @volume.status } returns("Detached") { @volume.status }
end end
tests('Fog::Compute::IBM::Volume#destroy') do tests('Fog::Storage::IBM::Volume#destroy') do
returns(true) { @volume.destroy } returns(true) { @volume.destroy }
end end

View file

@ -1,4 +1,4 @@
Shindo.tests('Fog::Compute[:ibm] | volume requests', ['ibm']) do Shindo.tests('Fog::Storage[:ibm] | volume requests', ['ibm']) do
@combined_volume_format = { @combined_volume_format = {
"id" => String, "id" => String,
@ -50,11 +50,11 @@ Shindo.tests('Fog::Compute[:ibm] | volume requests', ['ibm']) do
end end
tests("#list_volumes").formats(@volumes_format) do tests("#list_volumes").formats(@volumes_format) do
Fog::Compute[:ibm].list_volumes.body Fog::Storage[:ibm].list_volumes.body
end end
tests("#get_volume('#{@volume_id}')").formats(@volume_format) do tests("#get_volume('#{@volume_id}')").formats(@volume_format) do
Fog::Compute[:ibm].get_volume(@volume_id).body Fog::Storage[:ibm].get_volume(@volume_id).body
end end
tests("#attach_volume('#{@instance_id}','#{@volume_id}')") do tests("#attach_volume('#{@instance_id}','#{@volume_id}')") do