Sha256: 02229dfc1dadf841417e9fa7cbe9848e5c345e53da81d93bdb0028432c091a44

Contents?: true

Size: 1.66 KB

Versions: 28

Compression:

Stored size: 1.66 KB

Contents

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

class CloudProviderInstanceTest < Test::Unit::TestCase
  
  def setup
    @inst = CloudProviders::CloudProviderInstance.new(
              :keypair_name => 'test_key',
              :status       => 'pending'
            )
  end
  
  def test_default_options
    assert_nil @inst.public_ip
    assert_nil @inst.internal_ip
    assert_nil @inst.launch_time
    assert_nil @inst.name
    assert_equal 'test_key', @inst.keypair_name
  end
  
  def test_pending_status
    assert 'pending', @inst.status
    assert @inst.pending?
    assert !@inst.running?
    assert !@inst.terminated?
    assert !@inst.terminating?
  end
  
  def test_valid
    assert !@inst.valid?  #no ip or name
    @inst.internal_ip = '10.0.0.1'
    @inst.name = 'fruby'
    assert @inst.valid?
  end

  def test_blank_public_ip_is_invalid
    @inst.public_ip = ''
    assert ! @inst.wait_for_public_ip(1)
  end

  def test_zero_public_ip_is_invalid
    @inst.public_ip = '0.0.0.0'
    assert ! @inst.wait_for_public_ip(1)
  end

  def test_nil_public_ip_is_invalid
    @inst.public_ip = nil
    assert ! @inst.wait_for_public_ip(1)
  end

  def test_wait_for_public_ip
    @inst.public_ip = '10.0.0.1'
    assert @inst.wait_for_public_ip(1)
  end
  
  # Not quite an amazing test, but better than nothing to share
  # that the port is open.
  def test_wait_for_port
    @inst.class.send(:define_method, :is_port_open?) {false}
    assert !@inst.wait_for_port(22, :timeout => 20, :retry_times => 1)
    @inst.class.send(:define_method, :is_port_open?) {true}
    assert @inst.wait_for_port(80)
  end
  
  def test_terminate!
    assert_respond_to @inst, :terminate!
  end
  
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
auser-poolparty-1.3.0 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.1 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.10 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.11 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.12 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.13 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.14 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.15 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.16 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.17 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.2 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.3 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.4 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.5 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.6 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.7 test/lib/cloud_providers/cloud_provider_instance_test.rb
auser-poolparty-1.3.8 test/lib/cloud_providers/cloud_provider_instance_test.rb
fairchild-poolparty-1.3.17 test/lib/cloud_providers/cloud_provider_instance_test.rb
fairchild-poolparty-1.3.5 test/lib/cloud_providers/cloud_provider_instance_test.rb
poolparty-1.3.15 test/lib/cloud_providers/cloud_provider_instance_test.rb