2009-08-17 18:55:30 -04:00
|
|
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2009-07-26 22:22:27 -04:00
|
|
|
|
|
|
|
describe 'EC2.detach_volume' do
|
2009-08-19 23:32:57 -04:00
|
|
|
describe 'success' do
|
2009-07-26 22:22:27 -04:00
|
|
|
|
2009-08-19 23:32:57 -04:00
|
|
|
before(:each) do
|
|
|
|
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
|
|
|
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
|
|
|
eventually(128) do
|
2009-08-25 22:49:55 -04:00
|
|
|
ec2.attach_volume(@instance_id, @volume_id, '/dev/sdh')
|
2009-08-19 23:32:57 -04:00
|
|
|
end
|
2009-07-26 22:22:27 -04:00
|
|
|
end
|
|
|
|
|
2009-08-19 23:32:57 -04:00
|
|
|
after(:each) do
|
|
|
|
eventually do
|
|
|
|
ec2.delete_volume(@volume_id)
|
|
|
|
ec2.terminate_instances([@instance_id])
|
|
|
|
end
|
2009-07-26 22:22:27 -04:00
|
|
|
end
|
|
|
|
|
2009-08-19 23:32:57 -04:00
|
|
|
it "should return proper attributes" do
|
|
|
|
eventually do
|
|
|
|
actual = ec2.detach_volume(@volume_id)
|
|
|
|
actual.body['attachTime'].should be_a(Time)
|
|
|
|
actual.body['device'].should be_a(String)
|
|
|
|
actual.body['instanceId'].should be_a(String)
|
|
|
|
actual.body['requestId'].should be_a(String)
|
|
|
|
actual.body['status'].should be_a(String)
|
|
|
|
actual.body['volumeId'].should be_a(String)
|
|
|
|
end
|
2009-07-26 22:22:27 -04:00
|
|
|
end
|
|
|
|
|
2009-08-19 23:32:57 -04:00
|
|
|
end
|
2009-08-25 22:49:55 -04:00
|
|
|
describe 'failure' do
|
|
|
|
|
|
|
|
it "should raise a BadRequest error if the volume does not exist" do
|
|
|
|
lambda {
|
|
|
|
ec2.detach_volume('vol-00000000')
|
|
|
|
}.should raise_error(Fog::Errors::BadRequest)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-08-19 23:32:57 -04:00
|
|
|
end
|