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/ec2/describe_instances_spec.rb

78 lines
3.3 KiB
Ruby
Raw Normal View History

2009-07-06 23:45:16 -04:00
require File.dirname(__FILE__) + '/../../spec_helper'
2009-07-09 00:58:02 -04:00
describe 'EC2.describe_instances' do
2009-07-06 23:45:16 -04:00
before(:all) do
run_instances = ec2.run_instances('ami-5ee70037', 1, 1).body
@instance_id = run_instances[:instances_set].first[:instance_id]
@reservation_id = run_instances[:reservation_id]
end
after(:all) do
ec2.terminate_instances([@instance_id])
end
2009-07-06 23:45:16 -04:00
it "should return proper attributes with no params" do
actual = ec2.describe_instances
reservation = actual.body[:reservation_set].select {|reservation| reservation[:reservation_id] == @reservation_id}.first
reservation[:group_set].should be_an(Array)
reservation[:group_set].first.should be_a(String)
reservation[:owner_id].should be_a(String)
reservation[:reservation_id].should be_a(String)
instance = reservation[:instances_set].select {|instance| instance[:instance_id] == @instance_id}.first
instance[:ami_launch_index].should be_an(Integer)
instance[:dns_name].should be_a(String)
instance[:image_id].should be_a(String)
instance[:instance_id].should be_a(String)
instance[:instance_state].should be_a(Hash)
state = instance[:instance_state]
state[:code].should be_a(String)
state[:name].should be_a(String)
instance[:instance_type].should be_a(String)
instance[:kernel_id].should be_a(String)
# instance[:key_name].should be_a(String)
instance[:launch_time].should be_a(Time)
instance[:monitoring].should be_a(Hash)
[true, false].should include(instance[:monitoring][:state])
instance[:placement].should be_an(Array)
instance[:placement].first.should be_a(String)
instance[:private_dns_name].should be_a(String)
instance[:product_codes].should be_an(Array)
# instance[:product_codes].first.should be_a(String)
instance[:ramdisk_id].should be_a(String)
instance[:reason].should be_a(String)
2009-07-06 23:45:16 -04:00
end
it "should return proper attributes with params" do
actual = ec2.describe_instances(@instance_id)
reservation = actual.body[:reservation_set].select {|reservation| reservation[:reservation_id] == @reservation_id}.first
reservation[:group_set].should be_an(Array)
reservation[:group_set].first.should be_a(String)
reservation[:owner_id].should be_a(String)
reservation[:reservation_id].should be_a(String)
instance = reservation[:instances_set].select {|instance| instance[:instance_id] == @instance_id}.first
instance[:ami_launch_index].should be_an(Integer)
instance[:dns_name].should be_a(String)
instance[:image_id].should be_a(String)
instance[:instance_id].should be_a(String)
instance[:instance_state].should be_a(Hash)
state = instance[:instance_state]
state[:code].should be_a(String)
state[:name].should be_a(String)
instance[:instance_type].should be_a(String)
instance[:kernel_id].should be_a(String)
# instance[:key_name].should be_a(String)
instance[:launch_time].should be_a(Time)
instance[:monitoring].should be_a(Hash)
[true, false].should include(instance[:monitoring][:state])
instance[:placement].should be_an(Array)
instance[:placement].first.should be_a(String)
instance[:private_dns_name].should be_a(String)
instance[:product_codes].should be_an(Array)
# instance[:product_codes].first.should be_a(String)
instance[:ramdisk_id].should be_a(String)
instance[:reason].should be_a(String)
end
2009-07-06 23:45:16 -04:00
end