Sha256: c887c9ab6d0d5edb0bfb79f4ed14ee2e47f50d690ebf5def5dac11b934d95061

Contents?: true

Size: 1.94 KB

Versions: 12

Compression:

Stored size: 1.94 KB

Contents

require '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

12 entries across 12 versions & 2 rubygems

Version Path
fog-0.7.1 spec/aws/models/compute/snapshot_spec.rb
fog-0.7.0 spec/aws/models/compute/snapshot_spec.rb
fog-0.6.0 spec/aws/models/compute/snapshot_spec.rb
fog-0.5.3 spec/aws/models/compute/snapshot_spec.rb
fog-0.5.2 spec/aws/models/compute/snapshot_spec.rb
fog-0.5.1 spec/aws/models/compute/snapshot_spec.rb
fog-0.5.0 spec/aws/models/compute/snapshot_spec.rb
phpfog-fog-0.4.1.3 spec/aws/models/compute/snapshot_spec.rb
phpfog-fog-0.4.1.2 spec/aws/models/compute/snapshot_spec.rb
phpfog-fog-0.4.1.1 spec/aws/models/compute/snapshot_spec.rb
phpfog-fog-0.4.1 spec/aws/models/compute/snapshot_spec.rb
fog-0.4.1 spec/aws/models/compute/snapshot_spec.rb