mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|compute] Mock detach_volume should raise proper error if volume is not attached.
This commit is contained in:
parent
e8b7c9a36d
commit
4375cc77f8
2 changed files with 17 additions and 8 deletions
|
|
@ -41,14 +41,19 @@ module Fog
|
||||||
def detach_volume(volume_id, options = {})
|
def detach_volume(volume_id, options = {})
|
||||||
response = Excon::Response.new
|
response = Excon::Response.new
|
||||||
response.status = 200
|
response.status = 200
|
||||||
if (volume = self.data[:volumes][volume_id]) && !volume['attachmentSet'].empty?
|
if (volume = self.data[:volumes][volume_id])
|
||||||
data = volume['attachmentSet'].pop
|
if !volume['attachmentSet'].empty?
|
||||||
volume['status'] = 'available'
|
data = volume['attachmentSet'].pop
|
||||||
response.status = 200
|
volume['status'] = 'available'
|
||||||
response.body = {
|
response.status = 200
|
||||||
'requestId' => Fog::AWS::Mock.request_id
|
response.body = {
|
||||||
}.merge!(data)
|
'requestId' => Fog::AWS::Mock.request_id
|
||||||
response
|
}.merge!(data)
|
||||||
|
response
|
||||||
|
else
|
||||||
|
# real response has spacing issue below
|
||||||
|
raise Fog::Compute::AWS::Error.new("IncorrectState => Volume '#{volume_id}'is in the 'available' state.")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
raise Fog::Compute::AWS::NotFound.new("The volume '#{volume_id}' does not exist.")
|
raise Fog::Compute::AWS::NotFound.new("The volume '#{volume_id}' does not exist.")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,10 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
||||||
Fog::Compute[:aws].detach_volume('vol-00000000')
|
Fog::Compute[:aws].detach_volume('vol-00000000')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests("#detach_volume('#{@volume.identity}')").raises(Fog::Compute::AWS::Error) do
|
||||||
|
Fog::Compute[:aws].detach_volume(@volume.identity)
|
||||||
|
end
|
||||||
|
|
||||||
tests("#delete_volume('vol-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
tests("#delete_volume('vol-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
||||||
Fog::Compute[:aws].delete_volume('vol-00000000')
|
Fog::Compute[:aws].delete_volume('vol-00000000')
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue