Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ec2] spec related fixes
  • Loading branch information
geemus committed Apr 28, 2010
1 parent 14c2da7 commit 07dfb0f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/fog/aws/models/ec2/flavors.rb
Expand Up @@ -38,7 +38,7 @@ def all
end

def get(flavor_id)
all.detect {|flavor| flavor.id = flavor_id}
all.detect {|flavor| flavor.id == flavor_id}
end

end
Expand Down
11 changes: 6 additions & 5 deletions spec/aws/models/ec2/snapshot_spec.rb
Expand Up @@ -35,7 +35,7 @@
it "should return true if the snapshot is deleted" do
volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
snapshot = volume.snapshots.create
snapshot.wait_for { status == "completed" }
snapshot.wait_for { ready? }
snapshot.destroy.should be_true
volume.destroy
end
Expand Down Expand Up @@ -69,6 +69,7 @@

before(:each) do
@volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
@volume.wait_for { ready? }
@snapshot = @volume.snapshots.new
end

Expand All @@ -77,10 +78,9 @@
end

it "should return true when it succeeds" do
eventually do
@snapshot.save.should be_true
@snapshot.destroy
end
@snapshot.save.should be_true
@snapshot.wait_for { ready? }
@snapshot.destroy
end

it "should not exist in snapshots before save" do
Expand All @@ -90,6 +90,7 @@
it "should exist in snapshots after save" do
@snapshot.save
AWS[:ec2].snapshots.get(@snapshot.id).should_not be_nil
@snapshot.wait_for { ready? }
@snapshot.destroy
end

Expand Down
10 changes: 8 additions & 2 deletions spec/aws/models/ec2/snapshots_spec.rb
Expand Up @@ -19,8 +19,11 @@
it "should limit snapshots by volume if present" do
@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 }
@volume.wait_for { ready?}
@snapshot = @volume.snapshots.create
@other_volume.snapshots.all.map {|snapshot| snapshot.id}.should_not include(@snapshot.id)

@snapshot.wait_for { ready? }
@snapshot.destroy
@other_volume.destroy
@volume.destroy
Expand All @@ -32,10 +35,12 @@

before(:each) do
@volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
@volume.wait_for { ready? }
@snapshot = @volume.snapshots.create
end

after(:each) do
@snapshot.wait_for { ready? }
@snapshot.destroy
@volume.destroy
end
Expand All @@ -55,8 +60,9 @@
it "should return a Fog::AWS::EC2::Snapshot if a matching snapshot exists" do
volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
snapshot = volume.snapshots.create
snapshot.wait_for { ready? }
get = AWS[:ec2].snapshots.get(snapshot.id)
snapshot.attributes.reject {|key, value| [:progress, :status].include?(key)}.should == get.attributes.reject {|key, value| [:progress, :status].include?(key)}
snapshot.attributes.should == get.attributes
snapshot.destroy
end

Expand Down
6 changes: 3 additions & 3 deletions spec/aws/models/ec2/volume_spec.rb
Expand Up @@ -49,15 +49,15 @@
before(:each) do
@server = AWS[:ec2].servers.create(:image_id => GENTOO_AMI)
@volume = AWS[:ec2].volumes.new(:availability_zone => @server.availability_zone, :size => 1, :device => '/dev/sdz1')
@server.wait_for { state == 'running' }
@server.wait_for { ready? }
end

after(:each) do
@server.destroy
if @volume.id
@volume.wait_for { status == 'attached' }
@volume.wait_for { state == 'attached' }
@volume.server = nil
@volume.wait_for { status == 'available' }
@volume.wait_for { ready? }
@volume.destroy
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/aws/models/ec2/volumes_spec.rb
Expand Up @@ -40,8 +40,9 @@

it "should return a Fog::AWS::EC2::Volume if a matching volume exists" do
volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
volume.wait_for { ready? }
get = AWS[:ec2].volumes.get(volume.id)
volume.attributes.reject { |key, value| [:device, :status].include?(key) }.should == get.attributes.reject { |key, value| [:device, :status].include?(key) }
volume.attributes.should == get.attributes
volume.destroy
end

Expand Down
2 changes: 1 addition & 1 deletion spec/aws/models/s3/directories_spec.rb
Expand Up @@ -32,7 +32,7 @@
end

it "should return nil if no matching directory exists" do
AWS[:s3].directories.get('fogdirectoryname').should be_nil
AWS[:s3].directories.get('fognotadirectory').should be_nil
end

end
Expand Down

0 comments on commit 07dfb0f

Please sign in to comment.