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 = {})
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
if (volume = self.data[:volumes][volume_id]) && !volume['attachmentSet'].empty?
|
||||
data = volume['attachmentSet'].pop
|
||||
volume['status'] = 'available'
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id
|
||||
}.merge!(data)
|
||||
response
|
||||
if (volume = self.data[:volumes][volume_id])
|
||||
if !volume['attachmentSet'].empty?
|
||||
data = volume['attachmentSet'].pop
|
||||
volume['status'] = 'available'
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id
|
||||
}.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
|
||||
raise Fog::Compute::AWS::NotFound.new("The volume '#{volume_id}' does not exist.")
|
||||
end
|
||||
|
|
|
@ -109,6 +109,10 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
|||
Fog::Compute[:aws].detach_volume('vol-00000000')
|
||||
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
|
||||
Fog::Compute[:aws].delete_volume('vol-00000000')
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue