From 5775b8b5368ce6b608e1da637b4a61aa36b92733 Mon Sep 17 00:00:00 2001 From: Wesley Beary Date: Sun, 19 Jul 2009 14:14:08 -0700 Subject: [PATCH] describe_snapshot fixes/specs --- .../aws/requests/ec2/describe_snapshots.rb | 10 ++++++- spec/aws/ec2/describe_key_pairs_spec.rb | 12 ++++---- spec/aws/ec2/describe_snapshot_spec.rb | 29 +++++++++++++++++-- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/lib/fog/aws/requests/ec2/describe_snapshots.rb b/lib/fog/aws/requests/ec2/describe_snapshots.rb index 0e4b0ae69..dd9c8b1ce 100644 --- a/lib/fog/aws/requests/ec2/describe_snapshots.rb +++ b/lib/fog/aws/requests/ec2/describe_snapshots.rb @@ -8,7 +8,15 @@ module Fog # * snapshot_id<~Array> - List of snapshots to describe, defaults to all # # ==== Returns - # FIXME: docs + # * response<~Fog::AWS::Response>: + # * body<~Hash>: + # * :request_id<~String> - Id of request + # * :snapshot_set<~Array>: + # * :progress<~String>: The percentage progress of the snapshot + # * :snapshot_id<~String>: Id of the snapshot + # * :start_time<~Time>: Timestamp of when snapshot was initiated + # * :status<~String>: Snapshot state, in ['pending', 'completed'] + # * :volume_id<~String>: Id of volume that snapshot contains def describe_snapshots(snapshot_id = []) params = indexed_params('SnapshotId', snapshot_id) request({ diff --git a/spec/aws/ec2/describe_key_pairs_spec.rb b/spec/aws/ec2/describe_key_pairs_spec.rb index 79c6997e6..bd8847ae7 100644 --- a/spec/aws/ec2/describe_key_pairs_spec.rb +++ b/spec/aws/ec2/describe_key_pairs_spec.rb @@ -14,18 +14,18 @@ describe 'EC2.describe_key_pairs' do actual = ec2.describe_key_pairs actual.body[:key_set].should be_an(Array) actual.body[:request_id].should be_a(String) - key = actual.body[:key_set].select {|key| key[:key_name] == 'key_name' }.first - key[:key_name].should == 'key_name' - key[:key_fingerprint].should be_a(String) + key_pair = actual.body[:key_set].select {|key| key[:key_name] == 'key_name' }.first + key_pair[:key_fingerprint].should be_a(String) + key_pair[:key_name].should be_a(String) end it "should return proper attributes with params" do actual = ec2.describe_key_pairs(['key_name']) actual.body[:key_set].should be_an(Array) actual.body[:request_id].should be_a(String) - key = actual.body[:key_set].select {|key| key[:key_name] == 'key_name' }.first - key[:key_name].should == 'key_name' - key[:key_fingerprint].should be_a(String) + key_pair = actual.body[:key_set].select {|key| key[:key_name] == 'key_name' }.first + key_pair[:key_fingerprint].should be_a(String) + key_pair[:key_name].should be_a(String) end end diff --git a/spec/aws/ec2/describe_snapshot_spec.rb b/spec/aws/ec2/describe_snapshot_spec.rb index c924948b7..473b68e31 100644 --- a/spec/aws/ec2/describe_snapshot_spec.rb +++ b/spec/aws/ec2/describe_snapshot_spec.rb @@ -2,11 +2,36 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe 'EC2.describe_snapshots' do + before(:all) do + @volume_id = ec2.create_volume('us-east-1a', 1).body[:volume_id] + @snapshot_id = ec2.create_snapshot(@volume_id).body[:snapshot_id] + end + + after(:all) do + ec2.delete_volume(@volume_id) + eventually { ec2.delete_snapshot(@snapshot_id) } + end + it "should return proper attributes with no params" do actual = ec2.describe_snapshots - p actual + actual.body[:snapshot_set].should be_an(Array) + snapshot = actual.body[:snapshot_set].select {|snapshot| snapshot[:snapshot_id] == @snapshot_id}.first + snapshot[:progress].should be_a(String) + snapshot[:snapshot_id].should be_a(String) + snapshot[:start_time].should be_a(Time) + snapshot[:status].should be_a(String) + snapshot[:volume_id].should be_a(String) end - it "should return proper attributes with params" + it "should return proper attributes with params" do + actual = ec2.describe_snapshots([@snapshot_id]) + actual.body[:snapshot_set].should be_an(Array) + snapshot = actual.body[:snapshot_set].select {|snapshot| snapshot[:snapshot_id] == @snapshot_id}.first + snapshot[:progress].should be_a(String) + snapshot[:snapshot_id].should be_a(String) + snapshot[:start_time].should be_a(Time) + snapshot[:status].should be_a(String) + snapshot[:volume_id].should be_a(String) + end end