2009-09-29 22:02:33 -07:00
|
|
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
|
|
|
|
|
|
describe 'Fog::AWS::EC2::Snapshots' do
|
|
|
|
|
|
|
|
describe "#all" do
|
|
|
|
|
|
|
|
it "should return a Fog::AWS::EC2::Snapshots" do
|
2010-01-23 12:35:16 -08:00
|
|
|
AWS[:ec2].snapshots.all.should be_a(Fog::AWS::EC2::Snapshots)
|
2009-09-29 22:02:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should include persisted snapshots" do
|
2010-01-25 22:46:18 -08:00
|
|
|
@volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
|
|
|
eventually { @snapshot = @volume.snapshots.create }
|
|
|
|
AWS[:ec2].snapshots.all.map {|snapshot| snapshot.id}.should include(@snapshot.id)
|
|
|
|
@snapshot.destroy
|
|
|
|
@volume.destroy
|
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
|
|
|
@volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
|
|
|
@other_volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
|
|
|
eventually { @snapshot = @volume.snapshots.create }
|
|
|
|
@other_volume.snapshots.all.map {|snapshot| snapshot.id}.should_not include(@snapshot.id)
|
|
|
|
@snapshot.destroy
|
|
|
|
@other_volume.destroy
|
|
|
|
@volume.destroy
|
2009-09-29 22:02:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#create" do
|
|
|
|
|
|
|
|
before(:each) do
|
2010-01-23 12:35:16 -08:00
|
|
|
@volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
2009-09-29 22:02:33 -07:00
|
|
|
@snapshot = @volume.snapshots.create
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:each) do
|
|
|
|
@snapshot.destroy
|
|
|
|
@volume.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return a Fog::AWS::EC2::Snapshot" do
|
|
|
|
@snapshot.should be_a(Fog::AWS::EC2::Snapshot)
|
|
|
|
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-01-23 12:35:16 -08:00
|
|
|
volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
2009-09-29 22:02:33 -07:00
|
|
|
snapshot = volume.snapshots.create
|
2010-01-23 12:35:16 -08:00
|
|
|
get = AWS[:ec2].snapshots.get(snapshot.id)
|
2009-12-05 14:53:42 -08:00
|
|
|
snapshot.attributes.reject {|key, value| [:progress, :status].include?(key)}.should == get.attributes.reject {|key, value| [:progress, :status].include?(key)}
|
2009-09-29 22:02:33 -07:00
|
|
|
snapshot.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return nil if no matching address exists" do
|
2010-01-23 12:35:16 -08:00
|
|
|
AWS[:ec2].snapshots.get('vol-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
|