Sha256: e8f11d6cc9e510e58f825c6a15cb5fc6b6b43295b31854a933ba46f129bd5b09

Contents?: true

Size: 1.42 KB

Versions: 28

Compression:

Stored size: 1.42 KB

Contents

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

require fixtures_dir/'clouds/vmware_cloud'

class CloudProviders::Vmware
  def self.stubbed_output
    @stubbed_output ||= {}
  end
  def vmrun(cmd, o={})
    self.class.stubbed_output[cmd]
  end
end

class VmwareProviderTest < Test::Unit::TestCase
  
  def setup
    @provider = CloudProviders::Vmware.new(
                  :image_id => "testfile.vmx", 
                  :keypair => fixtures_dir/'keys/test_key'
                )
  end
  
  def test_vmrun_list
    stub_vmrun_call("list", ["Total running VMs: 0"])
    assert_equal [], @provider.describe_instances
    stub_vmrun_call("list", ["Total running VMs: 1", "#{ENV["HOME"]}/Documents/Virtual\ Machines\.localized/ubuntu.vmwarevm/ubuntu.vmx"])
    inst = @provider.describe_instances.first
    assert_equal CloudProviders::VmwareInstance, inst.class
    assert_equal "#{ENV["HOME"]}/Documents/Virtual\ Machines\.localized/ubuntu.vmwarevm/ubuntu.vmx", inst.instance_id
  end
  
  def test_run_instances
    vmx_path = "#{ENV["HOME"]}/Documents/Virtual\ Machines\.localized/ubuntu.vmwarevm/ubuntu.vmx"
    stub_vmrun_call("list", ["Total running VMs: 0"])
    stub_vmrun_call("run #{vmx_path}", [])
    assert_equal CloudProviders::VmwareInstance, @provider.run_instance(:image_id => vmx_path).class
  end
    
    
  private
  
  def stub_vmrun_call(cmd, output)
    CloudProviders::Vmware.stubbed_output[cmd] = output
  end
  
end

Version data entries

28 entries across 28 versions & 3 rubygems

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