Sha256: 43716d1be51496f7f3a18c39a478fe36f5f787ad03c9f46a6718500c1ea77d55

Contents?: true

Size: 1.98 KB

Versions: 36

Compression:

Stored size: 1.98 KB

Contents

require File.dirname(__FILE__) + '/../../../spec_helper'

describe 'Fog::AWS::Compute::Snapshot' do

  before(:all) do
    @volume = AWS[:compute].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

  describe "#initialize" do

    it "should remap attributes from parser" do
      snapshot = AWS[:compute].snapshots.new(
        'snapshotId'  => 'snap-00000000',
        'startTime'   => 'now',
        'volumeId'    => 'vol-00000000',
        'description' => 'taken for safety'
      )
      snapshot.id.should == 'snap-00000000'
      snapshot.created_at.should == 'now'
      snapshot.volume_id.should == 'vol-00000000'
      snapshot.description.should == 'taken for safety'
    end

  end

  describe "#destroy" do

    it "should return true if the snapshot is deleted" do
      @snapshot = @volume.snapshots.create
      @snapshot.wait_for { ready? }
      @snapshot.destroy.should be_true
      @snapshot = nil # avoid the after(:each) block
    end

  end

  describe "#reload" do

    before(:each) do
      @snapshot = @volume.snapshots.create
      @reloaded = @snapshot.reload
    end

    it "should match the original" do
      @reloaded.should be_a(Fog::AWS::Compute::Snapshot)
      @reloaded.attributes.should == @snapshot.attributes
    end

  end

  describe "#save" do

    it "should persist the snapshot" do
      @snapshot = @volume.snapshots.new
      AWS[:compute].snapshots.get(@snapshot.id).should be_nil
      @snapshot.save.should be_true
      AWS[:compute].snapshots.get(@snapshot.id).should_not be_nil
    end

    it "should allow a description" do
      @snapshot = @volume.snapshots.create(:description => 'taken for safety')
      AWS[:compute].snapshots.get(@snapshot.id).description.should == 'taken for safety'
    end

  end

end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
fog-0.4.0 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.34 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.33 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.32 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.31 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.30 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.29 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.28 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.27 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.26 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.25 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.24 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.23 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.22 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.21 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.20 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.19 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.18 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.17 spec/aws/models/compute/snapshot_spec.rb
fog-0.3.16 spec/aws/models/compute/snapshot_spec.rb