1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/spec/aws/models/ec2/snapshots_spec.rb

86 lines
2 KiB
Ruby
Raw Normal View History

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
AWS[:ec2].snapshots.all.map {|snapshot| snapshot.id}.should include(@snapshot.id)
2009-10-06 18:55:39 -07:00
end
it "should limit snapshots by volume if present" do
@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)
@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
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
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
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
AWS[:ec2].snapshots.all.reload.should be_a(Fog::AWS::EC2::Snapshots)
2009-09-29 22:02:33 -07:00
end
end
end