mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add Client.VolumeInUse to AWS delete_volume mock
delete_volume when a volume is attached to a server should fail with an exception.
This commit is contained in:
parent
baaef29061
commit
e737657216
2 changed files with 12 additions and 0 deletions
|
@ -29,6 +29,10 @@ module Fog
|
|||
def delete_volume(volume_id)
|
||||
response = Excon::Response.new
|
||||
if volume = @data[:volumes][volume_id]
|
||||
if volume["attachmentSet"].any?
|
||||
attach = volume["attachmentSet"].first
|
||||
raise Fog::AWS::EC2::Error.new("Client.VolumeInUse => Volume #{volume_id} is currently attached to #{attach["instanceId"]}")
|
||||
end
|
||||
@data[:deleted_at][volume_id] = Time.now
|
||||
volume['status'] = 'deleting'
|
||||
response.status = 200
|
||||
|
|
|
@ -43,6 +43,14 @@ describe 'Fog::AWS::EC2::Volume' do
|
|||
volume.destroy.should be_true
|
||||
end
|
||||
|
||||
it 'should fail if the volume is attached to an instance' do
|
||||
server = AWS[:ec2].servers.create(:image_id => GENTOO_AMI)
|
||||
server.wait_for { ready? }
|
||||
volume = AWS[:ec2].volumes.create(:availability_zone => server.availability_zone, :size => 1, :device => '/dev/sdz1')
|
||||
volume.server = server
|
||||
lambda { volume.destroy }.should raise_error
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#server=" do
|
||||
|
|
Loading…
Reference in a new issue