Sha256: 409e83721e22a3b5001fb7550fcb3709a22b92c4d7cb325e9a47b8fa84b0db27

Contents?: true

Size: 1.48 KB

Versions: 21

Compression:

Stored size: 1.48 KB

Contents

require "#{File.dirname(__FILE__)}/../../../test_helper"
require File.dirname(__FILE__)+"/ec2_test.rb"

class Ec2InstanceTest < Test::Unit::TestCase
  include CloudProviders

  def inst
    @inst ||= clouds['app'].describe_instances.first
  end
  
  def test_has_cloud_provider
    inst = CloudProviders::Ec2.new(:image_id => "ami-abc123").describe_instances.first
    assert_kind_of CloudProviders::Ec2, inst.cloud_provider
  end
  
  def test_hosts_file_listing_for
    #TODO
  end
  
  def test_to_s
    vals = inst.to_s.split("\t")
    assert_equal 3, vals.size
    assert_equal 'app', vals.first
  end
  
  def test_has_cloud_set_when_created_from_cloud
    assert_equal clouds['app'], clouds['app'].cloud_provider.cloud
    assert_equal clouds['app'], inst.cloud
    assert_equal 'app', inst.dsl_options[:cloud_name]
    assert_equal 'app', inst.to_hash[:cloud_name]
  end
  
  def test_cloud_keypair
    assert_equal  clouds['app'].keypair.to_s,  inst.keypair.to_s
  end

  def test_refresh!
    inst.status = 'testing'
    inst.public_ip = 'notanip'
    assert_equal 'testing',  inst.status
    assert_equal 'notanip', inst.public_ip
    inst.refresh!
    assert_equal '75.101.141.103', inst.public_ip
    assert_equal 'running', inst.status
  end
  
  def test_terminate!
    zombie =  inst.terminate!
    assert_equal 'shutting-down', zombie.status
    assert_kind_of Ec2Instance, zombie
  end
  
  
  #TODO: this needs better tests
  def test_wait_for_public_ip
    assert inst.wait_for_public_ip
  end
  
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
auser-poolparty-1.3.0 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.1 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.10 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.11 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.12 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.13 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.2 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.3 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.4 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.5 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.6 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.7 test/lib/cloud_providers/ec2/ec2_instance_test.rb
auser-poolparty-1.3.8 test/lib/cloud_providers/ec2/ec2_instance_test.rb
fairchild-poolparty-1.3.5 test/lib/cloud_providers/ec2/ec2_instance_test.rb
poolparty-1.3.13 test/lib/cloud_providers/ec2/ec2_instance_test.rb
poolparty-1.3.8 test/lib/cloud_providers/ec2/ec2_instance_test.rb
poolparty-1.3.7 test/lib/cloud_providers/ec2/ec2_instance_test.rb
poolparty-1.3.6 test/lib/cloud_providers/ec2/ec2_instance_test.rb
poolparty-1.3.4 test/lib/cloud_providers/ec2/ec2_instance_test.rb
poolparty-1.3.3 test/lib/cloud_providers/ec2/ec2_instance_test.rb