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:
parent
02fc7a2232
commit
5e679a641e
5 changed files with 40 additions and 18 deletions
|
@ -89,7 +89,6 @@ module Fog
|
|||
:keys => {},
|
||||
:locations => populate_locations,
|
||||
:private_keys => {},
|
||||
:volumes => {},
|
||||
:addresses => {}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -48,7 +48,7 @@ module Fog
|
|||
response.status = 404
|
||||
end
|
||||
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.
|
||||
response.status = 415
|
||||
else
|
||||
|
|
|
@ -48,8 +48,31 @@ module Fog
|
|||
|
||||
class Mock
|
||||
|
||||
def request(options)
|
||||
Fog::Mock.not_implemented
|
||||
def self.data
|
||||
@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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Shindo.tests('Fog::Compute[:ibm] | volume', ['ibm']) do
|
||||
Shindo.tests('Fog::Storage[:ibm] | volume', ['ibm']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
@ -10,8 +10,8 @@ Shindo.tests('Fog::Compute[:ibm] | volume', ['ibm']) do
|
|||
@size = "256"
|
||||
@offering_id = "20001208"
|
||||
|
||||
tests('Fog::Compute::IBM::Volume.new') do
|
||||
@volume = Fog::Compute[:ibm].volumes.new(
|
||||
tests('Fog::Storage::IBM::Volume.new') do
|
||||
@volume = Fog::Storage[:ibm].volumes.new(
|
||||
:name => @name,
|
||||
:format => @image_id,
|
||||
:location_id => @location_id,
|
||||
|
@ -21,36 +21,36 @@ Shindo.tests('Fog::Compute[:ibm] | volume', ['ibm']) do
|
|||
returns(@name) { @volume.name }
|
||||
end
|
||||
|
||||
tests('Fog::Compute::IBM::Volume#save') do
|
||||
tests('Fog::Storage::IBM::Volume#save') do
|
||||
returns(true) { @volume.save }
|
||||
returns(String) { @volume.id.class }
|
||||
@volume_id = @volume.id
|
||||
end
|
||||
|
||||
tests("Fog::Compute::IBM::Volume#instance") do
|
||||
tests("Fog::Storage::IBM::Volume#instance") do
|
||||
returns(nil) { @volume.instance }
|
||||
end
|
||||
|
||||
tests("Fog::Compute::IBM::Volume#location") do
|
||||
tests("Fog::Storage::IBM::Volume#location") do
|
||||
returns(Fog::Compute::IBM::Location) { @volume.location.class }
|
||||
end
|
||||
|
||||
tests('Fog::Compute::IBM::Volume#id') do
|
||||
tests('Fog::Storage::IBM::Volume#id') do
|
||||
returns(@volume_id) { @volume.id }
|
||||
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.
|
||||
# TODO: Fix this for real connections
|
||||
Fog::Compute[:ibm].get_volume(@volume_id)
|
||||
Fog::Storage[:ibm].get_volume(@volume_id)
|
||||
returns(true) { @volume.ready? }
|
||||
end
|
||||
|
||||
tests('Fog::Compute::IBM::Volume#status') do
|
||||
tests('Fog::Storage::IBM::Volume#status') do
|
||||
returns("Detached") { @volume.status }
|
||||
end
|
||||
|
||||
tests('Fog::Compute::IBM::Volume#destroy') do
|
||||
tests('Fog::Storage::IBM::Volume#destroy') do
|
||||
returns(true) { @volume.destroy }
|
||||
end
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
"id" => String,
|
||||
|
@ -50,11 +50,11 @@ Shindo.tests('Fog::Compute[:ibm] | volume requests', ['ibm']) do
|
|||
end
|
||||
|
||||
tests("#list_volumes").formats(@volumes_format) do
|
||||
Fog::Compute[:ibm].list_volumes.body
|
||||
Fog::Storage[:ibm].list_volumes.body
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
tests("#attach_volume('#{@instance_id}','#{@volume_id}')") do
|
Loading…
Add table
Reference in a new issue