2009-09-29 22:02:33 -07:00
|
|
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
|
|
|
|
|
|
describe 'Fog::AWS::EC2::Snapshots' do
|
|
|
|
|
2010-04-28 14:39:31 -07:00
|
|
|
before(:all) do
|
|
|
|
@volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
|
|
|
@volume.wait_for { ready? }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:all) do
|
|
|
|
@volume.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:each) do
|
|
|
|
if @snapshot && !@snapshot.new_record?
|
|
|
|
@snapshot.wait_for { ready? }
|
|
|
|
@snapshot.destroy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-09-29 22:02:33 -07:00
|
|
|
describe "#all" do
|
|
|
|
|
2010-04-28 14:39:31 -07:00
|
|
|
before(:each) do
|
|
|
|
@snapshot = @volume.snapshots.create
|
2009-09-29 22:02:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should include persisted snapshots" do
|
2010-01-25 22:46:18 -08:00
|
|
|
AWS[:ec2].snapshots.all.map {|snapshot| snapshot.id}.should include(@snapshot.id)
|
2009-10-06 18:55:39 -07:00
|
|
|
end
|
|
|
|
|
2009-12-05 14:53:42 -08:00
|
|
|
it "should limit snapshots by volume if present" do
|
2010-01-25 22:46:18 -08:00
|
|
|
@other_volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
2010-04-28 11:00:01 -07:00
|
|
|
|
2010-04-28 14:39:31 -07:00
|
|
|
@volume.snapshots.map {|snapshot| snapshot.id}.should include(@snapshot.identity)
|
|
|
|
@other_volume.snapshots.map {|snapshot| snapshot.id}.should_not include(@snapshot.identity)
|
|
|
|
|
2010-01-25 22:46:18 -08:00
|
|
|
@other_volume.destroy
|
2009-09-29 22:02:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#create" do
|
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
@snapshot = @volume.snapshots.create
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should exist on ec2" do
|
2010-01-23 12:35:16 -08:00
|
|
|
AWS[:ec2].snapshots.get(@snapshot.id).should_not be_nil
|
2009-09-29 22:02:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#get" do
|
|
|
|
|
|
|
|
it "should return a Fog::AWS::EC2::Snapshot if a matching snapshot exists" do
|
2010-04-28 14:39:31 -07:00
|
|
|
@snapshot = @volume.snapshots.create
|
|
|
|
@snapshot.wait_for { ready? }
|
|
|
|
get = AWS[:ec2].snapshots.get(@snapshot.id)
|
|
|
|
@snapshot.attributes.should == get.attributes
|
2009-09-29 22:02:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should return nil if no matching address exists" do
|
2010-05-27 11:27:08 -07:00
|
|
|
AWS[:ec2].snapshots.get('snap-00000000').should be_nil
|
2009-09-29 22:02:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#new" do
|
|
|
|
|
|
|
|
it "should return a Fog::AWS::EC2::Snapshot" do
|
2010-01-23 12:35:16 -08:00
|
|
|
AWS[:ec2].snapshots.new.should be_a(Fog::AWS::EC2::Snapshot)
|
2009-09-29 22:02:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#reload" do
|
|
|
|
|
|
|
|
it "should return a Fog::AWS::EC2::Snapshots" do
|
2010-01-23 12:35:16 -08:00
|
|
|
AWS[:ec2].snapshots.all.reload.should be_a(Fog::AWS::EC2::Snapshots)
|
2009-09-29 22:02:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|